473,386 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Having trouble deleting images that are generated dynamically

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>&nbsp;&nbsp;&nbsp;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")
%>
Nov 22 '16 #1
0 2931

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

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
2
by: ed | last post by:
i'm having trouble with a form. I want to be able to type in the address of the form with the data for the form items in the URL (ie: http://somesite.com/formpage.html?field1=data1&field2=data2)....
2
by: KraftDiner | last post by:
I have a list, and within it, objects are marked for deletion. However when I iterate through the list to remove objects not all the marked objects are deleted.. here is a code portion: i = 0...
1
by: Lauren Wilson | last post by:
I'm having trouble with the Access VBA help on my installation of A2K with Dev tools. Every time I try to retrieve help for items listed in the Object Browser (and SOME other items as well),...
2
by: Jozef | last post by:
Hello, I am trying to put together a module and open a workspace on a database that has a simple password (using Access XP). This is the lin that I'm having trouble with; Set wrk =...
0
by: Jozef | last post by:
Hello, I'm having trouble with the download links on my web server. The error I'm getting is; CGI Timeout The specified CGI application exceeded the allowed time for processing. The server...
4
by: Rico | last post by:
Hello, I have an MDE application where I use a bound object frame to display an image. This frame is updatable and bested on the contents of an OLE field. My problem is, some images display as...
2
by: Stu | last post by:
Hi guys, I've been having trouble getting the clock function to work portably, please could I get some thoughts? <Possibly OT comments> It works fine on my laptop (under WinXP) and on my...
0
by: Scott M. | last post by:
Hi, Can anyone tell me why my query doesn't work? I have a table called ECO Main with columns ECO Number and ECO Revision. I can see the data in my form, and I created a Delete Record button...
1
by: BarbQb | last post by:
Hi All, I am having trouble filtering a report with a multiselect list box. The report is generated, but it is not filtered based on the selections of the list box: lstVehID Multi Select...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.