PDA

View Full Version : Deleting Files Off The Server


Thatguy2001au
10-20-2002, 06:02 AM
Hi

I was hoping someone could help me with something. When a user presses on a certain link in my site, it deletes their record from the database. Now, they also have an image on the server which they uploaded when they added their record. That image is stored in a folder called "images" on the server and only a reference of the name of the file is made in the database. There is no reference of the path yet is know it to "classes\images\"

I am trying to use the fso to delete the file but i always get a "file not found error" if anyone has any ideas at all or could point me in the right direction then that will be much apprecieted. thanks. here is the code below.

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

objFSO.DeleteFile "class\images\" + (Recordset1.Fields.Item("AD_IMAGE").Value)

Set objFSO = Nothing

whammy
10-20-2002, 05:01 PM
You're not doing this AFTER you delete the record are you? ;)

Anyway, try Response.Writing this to your page:

Response.Write("class\images\" & (Recordset1.Fields.Item("AD_IMAGE").Value) )

In the appropriate place (like right before you try to delete the file in question) to see what the path is you're actually getting. As I was telling gcapp, that's always the first place to start, by printing out exactly what values the script is working with. :)

Thatguy2001au
10-20-2002, 05:12 PM
Thanks

I got it working now. I used the response.write thing u said and i found where the problem was.