Pure ASP Upload 3 Support Product Page
Update Record with New File Problems
Asked 06 Mar 2011 22:55:11
1
has this question
06 Mar 2011 22:55:11 J Vazq posted:
Hi, I just downloaded and installed the Pure ASP Upload 3. Ive read the manual and FAQs, and reviewed posts in the forums, but there doesn't appear to be an answer to my problem.
I'm using DW CS4; ASP javascript pages.
I'm having trouble updating an existing record's uploaded image. The record will update fields other than the file field, but it continues to show the image originally uploaded instead of the new one. The file IS being uploaded into the proper folder, just not called into the recordset. What am I doing wrong?
I have done:
1. Added the Update Record SB to the page first and saved it, then added the ASP Pure Upload 3 behavior.
2. Bound the filefields to the recordset.
3. NOT declared a page in the 'AFTER UPLOAD" section of the Pure ASP Upload 3 behavior (I did that in the Update Record behavior.
4. Selected "Overwrite" in the PureASP Upload 3 interface.
Thanks.
Replies
Replied 07 Mar 2011 11:38:37
07 Mar 2011 11:38:37 Miroslav Zografski replied:
Hello,
Try setting up Pure upload First and then the Update record SB.
Regards,
Try setting up Pure upload First and then the Update record SB.
Regards,
Replied 07 Mar 2011 22:11:19
07 Mar 2011 22:11:19 J Vazq replied:
Hi, thanks for the response.
I set up the Pure ASP Upload 3 server behavior before the Update Record behavior, and this is the error I see in DW when I attempt to save the page:
"When executing onLoad, the following Javascript error(s) occurred: At line 148 of file C:\Program Files\Dreamweaver CS4\Adobe Dreamweaver\Configuration\Commands\PureUpload_beforeSave.htm": The object is not currently contained in a document."
Any idea what that means? Thanks.
I set up the Pure ASP Upload 3 server behavior before the Update Record behavior, and this is the error I see in DW when I attempt to save the page:
"When executing onLoad, the following Javascript error(s) occurred: At line 148 of file C:\Program Files\Dreamweaver CS4\Adobe Dreamweaver\Configuration\Commands\PureUpload_beforeSave.htm": The object is not currently contained in a document."
Any idea what that means? Thanks.
Replied 08 Mar 2011 13:03:08
08 Mar 2011 13:03:08 Miroslav Zografski replied:
Hello,
Please, provide the code of the page in question.
Meanwhile clean your Dw cache and see if error is gone.
Regards,
Please, provide the code of the page in question.
Meanwhile clean your Dw cache and see if error is gone.
Regards,
Replied 08 Mar 2011 20:25:55
08 Mar 2011 20:25:55 J Vazq replied:
I cleared the cache as the page instructed; no change. The error still appears when I insert the ASP Pure Upload 3 behavior before the Update Record behavior.
Below is the entire code the page, which features primarily a simple form:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/JDP.asp" -->
<!--#include file="../ScriptLibrary/incPU3Class.asp" -->
<!--#include file="../ScriptLibrary/incPU3Utils.asp" -->
<%
//*** Pure ASP File Upload 3.0.17
// Process form form1
var pau = CreatePureUpload(), DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight;
pau.ScriptLibrary = "../ScriptLibrary";
pau.ConflictHandling = "over";
pau.StoreType = "file";
pau.UploadFolder = "";
var uploadPhoto = pau.AddField("Photo"
uploadPhoto.UploadFolder = "\"../uploads\"";
uploadPhoto.AllowedExtensions = "GIF,JPG,JPEG,BMP,PNG"; // "images"
pau.ProcessUpload();
pau.SaveAll();
%>
<%
// *** Edit Operations: (Modified for File Upload) declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME"
if (UploadQueryString) {
MM_editAction += "?" + Server.HTMLEncode(UploadQueryString);
}
// boolean to abort record edit
var MM_abortEdit = false;
%>
<%
if (String(Request("MM_update") == "form1" {
if (!MM_abortEdit) {
// execute the update
var MM_editCmd = Server.CreateObject ("ADODB.Command"
MM_editCmd.ActiveConnection = MM_JDP_STRING;
MM_editCmd.CommandText = "UPDATE Listings SET Address = ?, ShortDesc = ?, [Description] = ?, Price = ?, LinkTo = ?, Photos = ? WHERE ID = ?";
MM_editCmd.Prepared = true;
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Address")); // adVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param2", 203, 1, 536870910, Request.Form("ShortDesc")); // adLongVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param3", 203, 1, 536870910, Request.Form("Description")); // adLongVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("Price")); // adVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param5", 203, 1, 536870910, Request.Form("LinkTo")); // adLongVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("Photo")); // adVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param7", 5, 1, -1, (String(Request.Form("MM_recordId") != "undefined" && String(Request.Form("MM_recordId") != "" ? Request.Form("MM_recordId" : null)); // adDouble
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
// append the query string to the redirect URL
var MM_editRedirectUrl = "listings.asp";
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1) ? "?" : "&" + Request.QueryString;
}
Response.Redirect(MM_editRedirectUrl)
}
}
%>
<%
var rs_listings__MMColParam = "1";
if (String(Request.QueryString("ID") != "undefined" &&
String(Request.QueryString("ID") != "" {
rs_listings__MMColParam = String(Request.QueryString("ID");
}
%>
<%
var rs_listings_cmd = Server.CreateObject ("ADODB.Command"
rs_listings_cmd.ActiveConnection = MM_JDP_STRING;
rs_listings_cmd.CommandText = "SELECT * FROM Listings WHERE ID = ?";
rs_listings_cmd.Prepared = true;
rs_listings_cmd.Parameters.Append(rs_listings_cmd.CreateParameter("param1", 5, 1, -1, rs_listings__MMColParam)); // adDouble
var rs_listings = rs_listings_cmd.Execute();
var rs_listings_numRows = 0;
%>
<!-- InstanceBegin template="/Templates/admin.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JDP Site Administration</title>
<link href="../styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%">
<tr>
<td align="center" valign="top"><p><span class="headlines">J Dunn Properties Site Administration</span><br>
<a href="main.asp">Home</a></p>
<p> </p></td>
</tr>
<tr>
<td align="center" valign="top"><!-- InstanceBeginEditable name="content" -->
<table width="650" border="0">
<tr>
<td valign="top"><strong></strong><br>
<form action="<%=MM_editAction%>" method="POST" enctype="multipart/form-data" name="form1" id="form1" onSubmit="<%=pau.submitCode()%>;return document.MM_returnValue">
<table width="650" cellpadding="5">
<tr>
<td align="right">Property Address:</td>
<td><input name="Address" type="text" class="fields" id="Address" value="<%=(rs_listings.Fields.Item("Address".Value)%>" size="50"></td>
</tr>
<tr>
<td align="right">Short Description:<br>
(appears on home page)</td>
<td><textarea name="ShortDesc" cols="45" rows="5" class="fields" id="ShortDesc"><%=(rs_listings.Fields.Item("ShortDesc".Value)%></textarea></td>
</tr>
<tr>
<td align="right">Description:</td>
<td><textarea name="Description" cols="45" rows="5" class="fields" id="Description"><%=(rs_listings.Fields.Item("Description".Value)%></textarea></td>
</tr>
<tr>
<td align="right">List Price:</td>
<td><input name="Price" type="text" class="fields" id="Price" value="<%=(rs_listings.Fields.Item("Price".Value)%>"></td>
</tr>
<tr>
<td align="right">Link: </td>
<td><input name="LinkTo" type="text" class="fields" id="LinkTo" value="<%=(rs_listings.Fields.Item("LinkTo".Value)%>" size="70"></td>
</tr>
<tr>
<td align="right">Upload New Photo:</td>
<td><input name="Photo" type="file" class="fields" id="Photo" onChange="<%=uploadPhoto.validateCode()%>;return document.MM_returnValue" value="<%=(rs_listings.Fields.Item("Photos".Value)%>"></td>
</tr>
<tr>
<td> </td>
<td><input name="button" type="submit" class="fields" id="button" value="Submit"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rs_listings.Fields.Item("ID".Value %>">
<input type="hidden" name="upload_org_Photo" value="<%=(rs_listings.Fields.Item("Photos".Value)%>" />
</form></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</body>
<!-- InstanceEnd -->
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="../ScriptLibrary/incPU3.js" type="text/javascript"></script>
</html><%
rs_listings.Close();
%>
Below is the entire code the page, which features primarily a simple form:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/JDP.asp" -->
<!--#include file="../ScriptLibrary/incPU3Class.asp" -->
<!--#include file="../ScriptLibrary/incPU3Utils.asp" -->
<%
//*** Pure ASP File Upload 3.0.17
// Process form form1
var pau = CreatePureUpload(), DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight;
pau.ScriptLibrary = "../ScriptLibrary";
pau.ConflictHandling = "over";
pau.StoreType = "file";
pau.UploadFolder = "";
var uploadPhoto = pau.AddField("Photo"
uploadPhoto.UploadFolder = "\"../uploads\"";
uploadPhoto.AllowedExtensions = "GIF,JPG,JPEG,BMP,PNG"; // "images"
pau.ProcessUpload();
pau.SaveAll();
%>
<%
// *** Edit Operations: (Modified for File Upload) declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME"
if (UploadQueryString) {
MM_editAction += "?" + Server.HTMLEncode(UploadQueryString);
}
// boolean to abort record edit
var MM_abortEdit = false;
%>
<%
if (String(Request("MM_update") == "form1" {
if (!MM_abortEdit) {
// execute the update
var MM_editCmd = Server.CreateObject ("ADODB.Command"
MM_editCmd.ActiveConnection = MM_JDP_STRING;
MM_editCmd.CommandText = "UPDATE Listings SET Address = ?, ShortDesc = ?, [Description] = ?, Price = ?, LinkTo = ?, Photos = ? WHERE ID = ?";
MM_editCmd.Prepared = true;
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Address")); // adVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param2", 203, 1, 536870910, Request.Form("ShortDesc")); // adLongVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param3", 203, 1, 536870910, Request.Form("Description")); // adLongVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("Price")); // adVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param5", 203, 1, 536870910, Request.Form("LinkTo")); // adLongVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("Photo")); // adVarWChar
MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param7", 5, 1, -1, (String(Request.Form("MM_recordId") != "undefined" && String(Request.Form("MM_recordId") != "" ? Request.Form("MM_recordId" : null)); // adDouble
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
// append the query string to the redirect URL
var MM_editRedirectUrl = "listings.asp";
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1) ? "?" : "&" + Request.QueryString;
}
Response.Redirect(MM_editRedirectUrl)
}
}
%>
<%
var rs_listings__MMColParam = "1";
if (String(Request.QueryString("ID") != "undefined" &&
String(Request.QueryString("ID") != "" {
rs_listings__MMColParam = String(Request.QueryString("ID");
}
%>
<%
var rs_listings_cmd = Server.CreateObject ("ADODB.Command"
rs_listings_cmd.ActiveConnection = MM_JDP_STRING;
rs_listings_cmd.CommandText = "SELECT * FROM Listings WHERE ID = ?";
rs_listings_cmd.Prepared = true;
rs_listings_cmd.Parameters.Append(rs_listings_cmd.CreateParameter("param1", 5, 1, -1, rs_listings__MMColParam)); // adDouble
var rs_listings = rs_listings_cmd.Execute();
var rs_listings_numRows = 0;
%>
<!-- InstanceBegin template="/Templates/admin.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JDP Site Administration</title>
<link href="../styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%">
<tr>
<td align="center" valign="top"><p><span class="headlines">J Dunn Properties Site Administration</span><br>
<a href="main.asp">Home</a></p>
<p> </p></td>
</tr>
<tr>
<td align="center" valign="top"><!-- InstanceBeginEditable name="content" -->
<table width="650" border="0">
<tr>
<td valign="top"><strong></strong><br>
<form action="<%=MM_editAction%>" method="POST" enctype="multipart/form-data" name="form1" id="form1" onSubmit="<%=pau.submitCode()%>;return document.MM_returnValue">
<table width="650" cellpadding="5">
<tr>
<td align="right">Property Address:</td>
<td><input name="Address" type="text" class="fields" id="Address" value="<%=(rs_listings.Fields.Item("Address".Value)%>" size="50"></td>
</tr>
<tr>
<td align="right">Short Description:<br>
(appears on home page)</td>
<td><textarea name="ShortDesc" cols="45" rows="5" class="fields" id="ShortDesc"><%=(rs_listings.Fields.Item("ShortDesc".Value)%></textarea></td>
</tr>
<tr>
<td align="right">Description:</td>
<td><textarea name="Description" cols="45" rows="5" class="fields" id="Description"><%=(rs_listings.Fields.Item("Description".Value)%></textarea></td>
</tr>
<tr>
<td align="right">List Price:</td>
<td><input name="Price" type="text" class="fields" id="Price" value="<%=(rs_listings.Fields.Item("Price".Value)%>"></td>
</tr>
<tr>
<td align="right">Link: </td>
<td><input name="LinkTo" type="text" class="fields" id="LinkTo" value="<%=(rs_listings.Fields.Item("LinkTo".Value)%>" size="70"></td>
</tr>
<tr>
<td align="right">Upload New Photo:</td>
<td><input name="Photo" type="file" class="fields" id="Photo" onChange="<%=uploadPhoto.validateCode()%>;return document.MM_returnValue" value="<%=(rs_listings.Fields.Item("Photos".Value)%>"></td>
</tr>
<tr>
<td> </td>
<td><input name="button" type="submit" class="fields" id="button" value="Submit"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rs_listings.Fields.Item("ID".Value %>">
<input type="hidden" name="upload_org_Photo" value="<%=(rs_listings.Fields.Item("Photos".Value)%>" />
</form></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</body>
<!-- InstanceEnd -->
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="../ScriptLibrary/incPU3.js" type="text/javascript"></script>
</html><%
rs_listings.Close();
%>