Forums
This topic is locked
Deleting file after using Pure ASP Upload
18 Oct 2002 14:40:13 Phuc Ngo posted:
I use pure asp upload to populate a database with text and file names which are uploaded to the server. How do I delete the contents and the file all together. I have tried www.udzone.com/ShowDetail.asp?NewsId=594 but its only delete the contents from the database not the file itself from the upload folder. How do I get it to delete all both the content and the file.Thanks!
-Dave
The code I haave is below
<%
' *** Delete Record: construct a sql delete statement and execute it
If (CStr(Request("MM_delete") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql delete statement
MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the delete
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
' This is where we delete the file before we delete the record!
Set File = CreateObject("Scripting.FileSystemObject"
ImagePath = Server.MapPath("../documents"
ImagePath = ImagePath & "/" & (rsDelete.Fields.Item("txtFile".Value)
' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
Edited by - coolguyz on 18 Oct 2002 16:25:25
Replies
Replied 18 Oct 2002 16:23:42
18 Oct 2002 16:23:42 Phuc Ngo replied:
Please disregard post. I got it to work!
Missing a "/" at the end of ../documents
Thanks!
Edited by - coolguyz on 18 Oct 2002 16:25:55
Missing a "/" at the end of ../documents
Thanks!
Edited by - coolguyz on 18 Oct 2002 16:25:55