I have some code that basically looks into a directory, then populates a page, based on each image that resides in that folder. What I'm trying to do, is pass that string to an additional page, to have the ability to delete an image from that listing. Below is the code for the page (gallerydelete.asp) that generates the images:
<HTML>
<HEAD>
<TITLE>Photo Gallery Administration</TITLE>
</HEAD>
<BODY LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<TABLE BORDER="0" CELLSPACING="8" CELLPADDING="0">
<TR>
<TD><BR>
<class style="color:red; font-family:Tahoma; font-size: 14px"><B> Click Photos To Delete</B></class>
</TD>
</TR>
<TR>
<%
strPathInfo = Request.ServerVariables("SCRIPT_NAME")
strPhysicalPath = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ObjFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFSO.GetFolder("C:\wwwroot\gallery")
Set objFolderContents = objFolder.Files
For each objFileItem in objFolderContents
strText = objFileItem.Name
If not InStr(strText, ".asp") => 4 then
looper = looper +1
Response.Write "<TD STYLE=""padding-top: 1px; padding-right: 1px; padding-left: 1px; padding-bottom: 1px"" align=""center"" valign=""middle"" HEIGHT=""202"" Width=""276"" BACKGROUND=""../images/""><a href=""ULDelete.asp?DelFile=& objFileItem.Name &""><img src=""/gallery/" & objFileItem.Name & """ hspace=""0"" vspace=""0"" height=""184"" width=""256"" STYLE=""border-top: 1px #928E84 solid; border-right: 1px #928E84 solid; border-bottom: 1px #928E84 solid; border-left: 1px #928E84 solid""></a></td>"
END IF
IF looper = 3 THEN
Response.Write "</tr><tr>"
looper = 0
END IF
Next %>
</TR>
</TABLE>
</BODY>
</HTML>
And here is the page (ULDelete.asp) code that I'm using to try to delete a selected image:
<%
dim fs
Set fs=Server.CreateObject("Scripting.FileSystemObject ")
DelFile = Server.mappath("/gallery/& objFileItem.Name &")
if fs.FileExists(DelFile) then
fs.DeleteFile(DelFile)
end if
set fs=nothing
%>
<%
Response.Redirect("gallerydelete.asp")
%>