By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,867 Members | 1,981 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,867 IT Pros & Developers. It's quick & easy.

Having trouble deleting images that are generated dynamically

P: 1
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:

<TITLE>Photo Gallery Administration</TITLE>


<class style="color:red; font-family:Tahoma; font-size: 14px"><B>&nbsp;&nbsp;&nbsp;Click Photos To Delete</B></class>


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>"

IF looper = 3 THEN
Response.Write "</tr><tr>"
looper = 0
Next %>


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
end if
set fs=nothing

Nov 22 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.