Pure ASP Upload 3 Support Product Page

Problem inserting filename into db

Asked 04 Jun 2010 23:12:52
1
has this question
04 Jun 2010 23:12:52 William Ball posted:
I have set up a simple form to upload the filename (of the uploaded uploaded file) and a description into my db from the upload form. When I submit the form, the file is uploaded and there are not errors, but nothing is showing up in my Access DB. Here's my code, any help much appreciated!

<!--#include file="../ScriptLibrary/incPU3Class.asp" -->
<!--#include file="../ScriptLibrary/incPU3Utils.asp" -->
<!--#include file="../Connections/AVI.asp" -->
<%
'*** Pure ASP File Upload 3.0.17
' Process form form1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "../ScriptLibrary"
pau.ConflictHandling = "over"
pau.StoreType = "file"
pau.ProgressTemplate = "mac_look.htm"
pau.ProgressWidth = 400
pau.ProgressHeight = 100
pau.UploadFolder = "upload"
pau.ProcessUpload
pau.SaveAll
if pau.Done then
SetUploadFormRequest "filename",pau.Fields("upload".FileName
end if
if pau.Done then Response.Redirect "uploadSuccess.asp"
%>
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (UploadQueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(UploadQueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(UploadFormRequest("MM_insert") = "form1" Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command"
MM_editCmd.ActiveConnection = MM_AVI_STRING
MM_editCmd.CommandText = "INSERT INTO Upload ([description], filename) VALUES (?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, UploadFormRequest("description") ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, UploadFormRequest("filename") ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
End If
End If
%>

And the form:

<form action="<%=MM_editAction%>" method="post" enctype="multipart/form-data" name="form1" onSubmit="<%=pau.submitCode()%>;return document.MM_returnValue">
<table width="465" cellpadding="3">
<tr>
<td>Browse for file to upload:</td>
<td><label>
<input name="upload" type="file" id="upload" onChange="<%=pau.validateCode()%>;return document.MM_returnValue">
</label></td>
</tr>
<tr>
<td>Short description:</td>
<td><label>
<input type="text" name="description" id="description">
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="uploadButton" id="uploadButton" value="Upload File">
</label></td>
</tr>
</table>
<input name="filename" type="hidden" id="filename" value="<%= pau.Fields("upload".FileName %>">
<input type="hidden" name="MM_insert" value="form1">
</form>

Replies

Replied 12 Aug 2010 19:27:08
12 Aug 2010 19:27:08 Ian Webb replied:
Hi William!

This is your problem:
if pau.Done then Response.Redirect "uploadSuccess.asp"

You've supplied a redirect address in the PAU setup, so the script is redirecting to your success page immediately after the upload, before the database insert.

This is the sequence:
Upload files
Process images with SIP
Update database
Redirect to success page

Take the redirect out of PAU, and add it to the end of the Insert command.

Alternatively, move the Insert command above the Upload script

Cheers, Ian.
Replied 17 Aug 2010 11:48:09
17 Aug 2010 11:48:09 Karin Gustafsson replied:
I have a similar problem.
My page looks like this at the moment.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../ScriptLibrary/incPU3Class.asp" -->
<!--#include file="../../ScriptLibrary/incPU3Utils.asp" -->

<
%'*** Pure ASP File Upload 3.0.17
' Process form form1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "../../ScriptLibrary"
pau.TimeOut = 30
pau.ConflictHandling = "over"
pau.StoreType = "file"
pau.ProgressTemplate = "classic.htm"
pau.ProgressWidth = 300
pau.ProgressHeight = 100
pau.UploadFolder = """filer/upload3"""
pau.ProcessUpload
pau.SaveAll

if pau.Done then 
	filename = "1.asp"
end if

if pau.Done then Response.Redirect "ok.asp?filename=" & filename & ""
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload file</title>
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="../../ScriptLibrary/incPU3.js" type="text/javascript"></script>
</head>

<body>

<p>Upload file</p>
<form action="<%=DMX_uploadAction%>" method="post" enctype="multipart/form-data" name="form1" id="form1" onSubmit="<%=pau.submitCode()%>;return document.MM_returnValue">
<input name="fileField" type="file" id="fileField" onchange="<%=pau.validateCode()%>;return document.MM_returnValue" />
    <input type="submit" name="button" id="button" value="Upload" />
</form>

<p>&nbsp;</p>

</body>
</html>


At the line that says filename = "1.asp"
I would like to insert the uploaded file's filename, but I just dont get it, whatever I write, it doesn't work.
When I put "1.asp" it naturally works, but if I want the dynamic filename... no!

Please help me!
Replied 17 Aug 2010 13:00:14
17 Aug 2010 13:00:14 Miroslav Zografski replied:
Hello Karin,

Check the following FAQ;
www.dmxzone.com/go?3798

it is regarding exactly your problem.

Regards,
Replied 17 Aug 2010 15:55:08
17 Aug 2010 15:55:08 Karin Gustafsson replied:
Thank You Miroslav!

I will test this tomorrow when I´m back at work.
Replied 18 Aug 2010 15:20:45
18 Aug 2010 15:20:45 Karin Gustafsson replied:
Works just perfectly!

Thanx again!
Replied 19 Aug 2010 10:16:40
19 Aug 2010 10:16:40 Miroslav Zografski replied:
Hello , you are welcome.

Regards,

Reply to this topic