Forums

This topic is locked

Deleting a record AND a file

Posted 19 Mar 2002 10:21:29
1
has voted
19 Mar 2002 10:21:29 Per Sommer posted:
Hi!

I'm having problems figuring out how to delete a record AND the corresponding file for that record.

When creating a record I have modified the DU script to work with ASPupload so I can upload a picture when inserting a record to the access database. Which works fine. But when deleting a record I would like to delete the file also. The form action <%=MM_editAction%> only deletes the record entry and not the file. I’ve been looking the MM_editAction through over and over again and I simply don’t get it... I don’t even understand how it actually deletes the record.

I was hoping somebody could help me figure out this problem since I have no clue on where to start.

Regards
Summer

Replies

Replied 19 Mar 2002 11:53:51
19 Mar 2002 11:53:51 Owen Eastwick replied:
Use FSO (File System Object) to delete the file, something like:

<%
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
varFile = "C:\YourWebDirectory\YourSiteDirectory\YourUploadDirectory\" & Request("ImageFileName"
objFSO.DeleteFile varFile, True
%>

NOTE you need to specifiy the real directory structure NOT the virtual i.e. C:/inetpub/wwwroot....

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 19 Mar 2002 20:19:26
19 Mar 2002 20:19:26 Mike Anderson replied:
This is just what I was looking for...but I still need help. Forgive me for my lack of knowledge, but how do I place this input type in the form that will delete the file and the database entry?

For example, the user selects the file to delete from a list of files. This directs them to a new asp page with a form to delete the file. They can delete the database entry but not the file without this delete file object. Do I place the object script as a hidden field?

Thanks for your help!

Replied 19 Mar 2002 21:36:05
19 Mar 2002 21:36:05 Per Sommer replied:

Reply to this topic