musicradiolive Posted December 30, 2006 Share Posted December 30, 2006 Hi.I've currently got a script that allows my users to upload files on to the server, and also to view hat files already exist on the server in a specific folder. Can i adapt this to make it able to delete files from that folder? <%Function ShowImageForType(strName) Dim strTemp strTemp = strName If strTemp <> "dir" Then strTemp = LCase(Right(strTemp, Len(strTemp) - InStrRev(strTemp, ".", -1, 1))) End If Select Case strTemp Case "asp" strTemp = "asp" Case "dir" strTemp = "dir" Case "htm", "html" strTemp = "htm" Case "gif", "jpg" strTemp = "img" Case "txt" strTemp = "txt" Case Else strTemp = "misc" End Select strTemp = "<IMG SRC=""./images/dir_" & strTemp & ".gif"" WIDTH=16 HEIGHT=16 BORDER=0>" ShowImageForType = strTempEnd Function%><%Dim strPath Dim objFSO Dim objFolderDim objItemstrPath = "/uploads/"Set objFSO = Server.CreateObject("Scripting.FileSystemObject")Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))%>Contents of <B>www.musicradiolive.com<%= strPath %></B><BR><BR><TABLE BORDER="5" BORDERCOLOR="green" CELLSPACING="0" CELLPADDING="2"> <TR BGCOLOR="#006600"> <TD><FONT COLOR="#FFFFFF"><B>File Name:</B></FONT></TD> <TD><FONT COLOR="#FFFFFF"><B>File Size (bytes):</B></FONT></TD> <TD><FONT COLOR="#FFFFFF"><B>Date Created:</B></FONT></TD> <TD><FONT COLOR="#FFFFFF"><B>File Type:</B></FONT></TD> </TR><%For Each objItem In objFolder.SubFolders If InStr(1, objItem, "_vti", 1) = 0 Then %> <TR BGCOLOR="#CCFFCC"> <TD ALIGN="left" ><%'= ShowImageForType("dir") %><A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD> <TD ALIGN="right"><%= objItem.Size %></TD> <TD ALIGN="left" ><%= objItem.DateCreated %></TD> <TD ALIGN="left" ><%= objItem.Type %></TD> </TR> <% End IfNext 'objItemFor Each objItem In objFolder.Files %> <TR BGCOLOR="#CCFFCC"> <TD ALIGN="left" ><%'= ShowImageForType(objItem.Name) %><A HREF="<%= strPath & objItem.Name %>"><%= objItem.Name %></A></TD> <TD ALIGN="right"><%= objItem.Size %></TD> <TD ALIGN="left" ><%= objItem.DateCreated %></TD> <TD ALIGN="left" ><%= objItem.Type %></TD> </TR> <%Next 'objItemSet objItem = NothingSet objFolder = NothingSet objFSO = Nothing%></TABLE> Thanks very muchJon Link to comment Share on other sites More sharing options...
justsomeguy Posted January 3, 2007 Share Posted January 3, 2007 There is a delete method on the File object. e.g. objItem.delete Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now