close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Cannot use Request.Form collection after calling BinaryRead

Thread began 12/10/2009 1:48 pm by info289797 | Last modified 12/22/2009 1:21 pm by info289797 | 8513 views | 18 replies |

info289797

Cannot use Request.Form collection after calling BinaryRead

I am wanting to upload an image onto the same page as the add to cart page. The error message is Cannot use Request.Form collection after calling BinaryRead. Is this problem fixed in Digital File Pro 2?

Sign in to reply to this post

Eric Mittman

When uploading files with a form on an ASP page the file upload object that gets created takes the place of the Request.Form.

To resolve the problem do a find and replace on the page for:

Find
Request.Form

Replace with
WA_DFP_UploadObj.Form

Digital File Pro 2 is PHP only so this is not an issue.

Sign in to reply to this post

info289797

I have done that and now get the error message:

Cannot use the generic Request collection after calling BinaryRead.

Sign in to reply to this post

Eric Mittman

This is the same issue, it would seem that there is a part of the page that you have not updated to use the upload object code instead of the request object code. If you cannot spot this in the code please post back with a copy of this page and I will take a look to see if I can spot the issue. If you post back with the page please include any additional info about the error like a line number or anything else.

Sign in to reply to this post

info289797

(The error message Cannot use the generic Request collection after calling BinaryRead is on the 2nd line below)


<%
var Recordset1__MMColParam = "77";
if (String(Request("MM_EmptyValue")) != "undefined" &&
String(Request("MM_EmptyValue")) != "") {
Recordset1__MMColParam = String(Request("MM_EmptyValue"));
}
%>
<%
var Recordset1_cmd = Server.CreateObject ("ADODB.Command");
Recordset1_cmd.ActiveConnection = MM_GIFTS_DB_STRING;
Recordset1_cmd.CommandText = "SELECT * FROM Product1 WHERE ID = ?";
Recordset1_cmd.Prepared = true;
Recordset1_cmd.Parameters.Append(Recordset1_cmd.CreateParameter("param1", 5, 1, -1, Recordset1__MMColParam)); // adDouble

var Recordset1 = Recordset1_cmd.Execute();
var Recordset1_numRows = 0;

WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(String(WA_DFP_UploadObj.Form("UploadImage")) != "undefined"){
WA_DFP_UploadFile("WA_UploadResult1", "file", "Images/161_1_1_medium.jpg", "pics/", "[FileName]", "2", "[FileName]_[Increment]", "20074", "false", "0", "0");
}
%>
<%
// WA eCart AddToCart
if (String(WA_DFP_UploadObj.Form("WA_eCart1_1_ATC")) != "undefined" || String(WA_DFP_UploadObj.Form("WA_eCart1_1_ATC.x")) != "undefined") {
var ATC_itemID = String(WA_DFP_UploadObj.Form("WA_eCart1_1_ID_Add"));
var ATC_AddIfIn = 0;
var ATC_RedirectAfter = "cart2.asp";
var ATC_RedirectIfIn = "";
var ATC_itemName = "" + String((Recordset1.Fields.Item("Product").Value)) + "";// column binding
var ATC_itemDescription = "" + String((Recordset1.Fields.Item("Description").Value)) + "";// column binding
var ATC_itemWeight = parseFloat("0");// column binding
var ATC_itemQuantity = "" + String(WA_DFP_UploadObj.Form("WA_eCart1_1_Quantity_Add")) + "";// column binding
var ATC_itemPrice = parseFloat("" + String((Recordset1.Fields.Item("Price").Value)) + "");// column binding
var ATC_itemImage = "";// column binding
var ATC_itemSize = "";// column binding
ATC_itemQuantity = parseFloat(ATC_itemQuantity);
if (!isNaN(ATC_itemQuantity) && ATC_itemQuantity != 0) {
WA_eCart1.AddToCart(ATC_AddIfIn, ATC_RedirectIfIn, ATC_itemID, ATC_itemName, ATC_itemDescription, ATC_itemWeight, ATC_itemQuantity, ATC_itemPrice, ATC_itemImage, ATC_itemSize);
if (ATC_RedirectAfter != "" && WA_eCart1_redirStr == "") {
WA_eCart1_redirStr = ATC_RedirectAfter;
}
Session("WAEC_ContinueRedirect") = String(Request.ServerVariables("Script_Name")) + "?" + String(Request.QueryString());
}
}
%>
<%
// WA eCart Redirect
if (WA_eCart1_redirStr != "") {
Response.Redirect(WA_eCart1_redirStr);
}
%>
<%
if(String(WA_DFP_UploadObj.Form("UploadImage")) != "undefined") {
Session("imageupload") = "" + String(WA_DFP_UploadStatus["WA_UploadResult1"].uploadFolder) + "/" + String(WA_DFP_UploadStatus["WA_UploadResult1"].serverFileName) + "";
}
%>
<body bgcolor="#D38AFF">
<script language="JavaScript1.2">mmLoadMenus();</script>
<p><a href="cart.asp"><img src="WA_eCart/Images/Pacifica/Btn1_EN_viewcart.gif" border="0" value="View Cart" name="WA_eCart1_View_1" alt="Total: <%=WA_eCart_DisplayMoney(WA_eCart1, WA_eCart1.GrandTotal())%>"></a></p>
<table width="86%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="3%" bgcolor="#D38AFF">&nbsp;</td>
<td width="93%" bgcolor="#FFFFFF">&nbsp;</td>
<td width="4%" bgcolor="#D38AFF">&nbsp;</td>
</tr>
<tr bordercolor="#D38AFF" bgcolor="#D38AFF">
<td bgcolor="#D38AFF">&nbsp;</td>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td bgcolor="#D38AFF">&nbsp;</td>
</tr>
<tr>
<td height="644" bgcolor="#D38AFF">&nbsp;</td>
<td valign="top" bgcolor="#FFFFFF"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="top">
<td height="28" colspan="3"><p>&nbsp;</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td width="446" valign="top" class="dotLineCell">&nbsp;</td>
<td width="282" height="20"><img src="Images/spacer.gif" width="1" height="1"></td>
<td width="23" height="20">&nbsp;</td>
</tr>
<tr>
<td width="446" height="448" align="center" valign="top" class="style1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="42%"><div align="left"><strong></strong></div></td>
<td width="58%"><div align="center"><strong><font color="#000000">
Upload your image here</font></strong> </div>
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#9CBCCF">
<tr>
<td> <div align="right"></div></td>
<td> <table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><strong><img src="<%= Session("imageupload") %>" width="250" height="250" align="texttop"></strong></div></td>
</tr>
</table></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p></td>
</tr>
</table>
<p align="right" class="mousemat">&nbsp;</p>
<div align="left"><strong></strong> </div>
<p align="center"><span class="style1"></span><%= Session("imageupload") %>
<% if (String(Session("imageupload")) != "undefined" || String(Session("imageupload")) != "") { %>
<% } %>
</p>
<p>&nbsp; </p>
</td>
<td width="282" align="left" valign="top">
<p align="center"><strong></strong><%=(Recordset1.Fields.Item("Product").Value)%></p>
<p align="center"><%=(Recordset1.Fields.Item("Price").Value)%></p>
<p align="center">&nbsp;
<form name="WA_eCart1_1_ATC_<%=(Recordset1.Fields.Item("ID").Value)%>" method="POST" action="<%=String(Request.ServerVariables("SCRIPT_NAME"))%><%=((String(Request.ServerVariables("QUERY_STRING")) != "undefined" && Request.ServerVariables("QUERY_STRING") != "")?"?"+Request.ServerVariables("QUERY_STRING"):"")%>">
<input type="hidden" name="WA_eCart1_1_ID_Add" value="<%=(Recordset1.Fields.Item("ID").Value)%>" >
<input type="text" name="WA_eCart1_1_Quantity_Add" value="1" size="4" >
<input type="image" src="WA_eCart/Images/Pacifica/Btn4_EN_addtocart.gif" border="0" value="Add to Cart" name="WA_eCart1_1_ATC">
</form>
</p>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<p align="center"><strong><em>Upload Image</em></strong></p>
<p align="center">
<input type="file" name="file">
</p>
<p align="center">
<input name="UploadImage" type="submit" id="UploadImage" value="UploadImage">
</p>
</form>
<p align="center">&nbsp;</p>
<form action="<a href="#" onClick="history.go(-1)">
<p align="center"> </p>
<p align="center"> </p>
</form>
<p>&nbsp;</p></td>
</tr>
</table>

Sign in to reply to this post

Eric Mittman

Have you tried updating these values to use the upload object instead like this:

WA_DFP_UploadObj.Form

<%
var Recordset1__MMColParam = "77";
if (String(WA_DFP_UploadObj.Form("MM_EmptyValue")) != "undefined" &&
String(WA_DFP_UploadObj.Form("MM_EmptyValue")) != "") {
Recordset1__MMColParam = String(WA_DFP_UploadObj.Form("MM_EmptyValue"));
}
%>



If the value comes from the querystring then you may need to update the code to reflect that.

Request.QueryString

Sign in to reply to this post

info289797

I have done that and the error message disappears, but when you click on add to cart nothing happens.

Sign in to reply to this post

Eric Mittman

You should try moving the rs code below the DFP upload code. So would want this code:

<%
var Recordset1__MMColParam = "77";
if (String(Request("MM_EmptyValue")) != "undefined" &&
String(Request("MM_EmptyValue")) != "") {
Recordset1__MMColParam = String(Request("MM_EmptyValue"));
}
%>
<%
var Recordset1_cmd = Server.CreateObject ("ADODB.Command");
Recordset1_cmd.ActiveConnection = MM_GIFTS_DB_STRING;
Recordset1_cmd.CommandText = "SELECT * FROM Product1 WHERE ID = ?";
Recordset1_cmd.Prepared = true;
Recordset1_cmd.Parameters.Append(Recordset1_cmd.CreateParameter("param1", 5, 1, -1, Recordset1__MMColParam)); // adDouble

var Recordset1 = Recordset1_cmd.Execute();
var Recordset1_numRows = 0;



To be just after this code:

WA_DFP_SetupUploadStatusStruct("WA_UploadResult1") ;
if(String(WA_DFP_UploadObj.Form("UploadImage")) != "undefined"){
WA_DFP_UploadFile("WA_UploadResult1", "file", "Images/161_1_1_medium.jpg", "pics/", "[FileName]", "2", "[FileName]_[Increment]", "20074", "false", "0", "0");



Please give this a try and let us know what the result is when you test the page. If you have any more problems with this please post back with the page in a zip archive so that we can look into this further.

Sign in to reply to this post

info289797

The same problem. The image adds ok, but when you click on add to cart, nothing happens.

Zip attached

Attached Files
uploadpage_new.zip
Sign in to reply to this post

Eric Mittman

I can see two problems on the page. The main issue that your add to cart is not working is because you are not submitting the add to cart form. Instead you have a separate form for the file field and this is the form that is being submitted. You will need to combine this form with the add to cart form just after it.

Along with moving the file field into the add to cart form you will also need to make sure it has a valid name and id. Finally, you will need to update the trigger for the upload to work with the add to cart button being pressed.

The other problem that I can see may not be affecting things but the server side code on your page is inside of the html code, it should be above it. You should move lines 65-151 to be just after line one. This is the proper place to put the server side code.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...