Pure ASP Upload Add On Pack Support Product Page

Not deleting file before record

Asked 10 Jan 2013 02:31:58
1
has this question
10 Jan 2013 02:31:58 Alejandro Mucino posted:
I have a page that deletes a record from an attachment but I want the file to be delted as well.
When I had the path using relative it worked fine, but we just recently switched to absolute and the upload works fine, the path is saved in a session variable.
But the deletion is not working. This is the code that deletes the record and the file.
After running record is deleted but the file remains.

----

<%
' *** Delete File Before Delete Record 1.8.2
If (CStr(Request("MM_delete") <> "" And CStr(Request("MM_recordId") <> "" Then
Dim DF_filesStr, DF_path, DF_suffix
DF_filesStr = "storage_name"
DF_path = "Session(\'Attachmentsfull\')"
DF_suffix = ""
DeleteFileBeforeRecord DF_filesStr,DF_path,MM_editConnection,MM_editTable,MM_editColumn,MM_recordId,DF_suffix
end if
%>




<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Delete Record: declare variables

if (CStr(Request("MM_delete") = "DeleteAttachment" And CStr(Request("MM_recordId") <> "" Then

MM_editConnection = MM_eimmigration_STRING
MM_editTable = "dbo.Attachments"
MM_editColumn = "attachment_id"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "UpdateAttachments.asp"

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.Form <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.Form <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.Form
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.Form
End If
End If

End If
%>





<%
' *** 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
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>

Replies

Replied 10 Jan 2013 02:36:07
10 Jan 2013 02:36:07 Alejandro Mucino replied:
Actually setting the path directly works !
But when I try to use the session varible instead (Absoulate path) doenst, what would the syntax be ?

This WORKS:

--

<%
' *** Delete File Before Delete Record 1.8.2
If (CStr(Request("MM_delete") <> "" And CStr(Request("MM_recordId") <> "" Then
Dim DF_filesStr, DF_path, DF_suffix
DF_filesStr = "storage_name"
DF_path = "../../../../BDotAttachments/BlueDotDev"
DF_suffix = ""
DeleteFileBeforeRecord DF_filesStr,DF_path,MM_editConnection,MM_editTable,MM_editColumn,MM_recordId,DF_suffix
end if
%>

--

I need to change the DF_path = Session("Attachmentsfull"
Replied 10 Jan 2013 02:38:49
10 Jan 2013 02:38:49 Alejandro Mucino replied:
Tried this: but no luck, no errors but the file is not deleted.

<%
' *** Delete File Before Delete Record 1.8.2
If (CStr(Request("MM_delete") <> "" And CStr(Request("MM_recordId") <> "" Then
Dim DF_filesStr, DF_path, DF_suffix
DF_filesStr = "storage_name"
DF_path = "Session('Attachmentsfull')"
DF_suffix = ""
DeleteFileBeforeRecord DF_filesStr,DF_path,MM_editConnection,MM_editTable,MM_editColumn,MM_recordId,DF_suffix
end if
%>
Replied 10 Jan 2013 02:43:59
10 Jan 2013 02:43:59 Alejandro Mucino replied:
Also check the value of the session in the page and it is correct. So it must definitely be the syntax that is needed to enter the session as the value.

I also tried using the value from the database directly and doesnt work either:

DF_path = "UploadAttach.Fields.Item('ParamVal').Value"

I rather use the session tho, so I don't have to create recordsets on all the pages in which I want to delete files, which are plenty in our internal system

So I need to know what the syntax is for :

DF_path = "Session('Attachmentsfull')"

And if there is any other change needed to indicate its an absolute path.

Thanks.

Replied 10 Jan 2013 19:14:03
10 Jan 2013 19:14:03 Alejandro Mucino replied:
One more thing, when i change to "absolute"

It changes the path of the included file to:

<!--#include virtual="/ScriptLibrary/incPUAddOn.asp" -->

When it first was

<!--#include file="../../ScriptLibrary/incPUAddOn.asp" -->

Evidently file cannot be found so I rest to

<!--#include file="../../ScriptLibrary/incPUAddOn.asp" -->

And it displays 'relative' path again ... how to fix this ?
Replied 11 Jan 2013 19:25:17
11 Jan 2013 19:25:17 Alejandro Mucino replied:
any help ???
This reply was removed on 1/14/2013 8:48:33 AM.
See the changelog
Replied 14 Jan 2013 08:49:07
14 Jan 2013 08:49:07 Vulcho Vulev replied:
Hello Alejandro.

Can you please send me your page at my e-mail:

Regards:Vulcho.

Reply to this topic