PDA

View Full Version : BinaryRead and Request.Form


DaveHope
04-13-2003, 10:56 AM
Okies, well, hello all. Now I'll get straight to the point, does anyone have a solution or workaround to using BinaryRead after using Request.Form? Whenever I try to do anything like that I get errors similar to:


Request object error 'ASP 0206 : 80004005'

Cannot call BinaryRead

/admin/upload_class.asp, line 148

Cannot call BinaryRead after using Request.Form collection.

Please be gentle ;) I'm still kinda new to ASP :D

raf
04-13-2003, 11:03 AM
Don't think there is a workaround. As sson as you call the request object, you need to stick with the method:

more info from the helpfile
---------------------------------------------------------------------
BinaryRead
The BinaryRead method retrieves data sent to the server from the client as part of a POST request. This method retrieves the data from the client and stores it in a SafeArray. A SafeArray is an array that contains information about the number of dimensions and the bounds of its dimensions.

Syntax
variant = Request.BinaryRead(count)

Parameters
variant
Contains an array of unsigned bytes returned by this method. This parameter will be of type VT_ARRAY | VT_UI1.
count
Before execution, specifies how many bytes to read from the client. After this method returns, count will contain the number of bytes successfully read from the client. The total number of bytes that will actually be read is less than or equal to Request.TotalBytes.
Remarks
The BinaryRead method is used to read the raw data sent by the client as part of a POST request. This method is used for low-level access to this data, as opposed to, for example, using the Request.Form collection to view form data sent in a POST request. Once you have called BinaryRead, referring to any variable in the Request.Form collection will cause an error. Conversely, once you have referred to a variable in the Request.Form collection, calling BinaryWrite will cause an error. Remember, if you access a variable in the Request collection without specifying which subcollection it belongs to, the Request.Form collection may be searched, bringing this rule into force.

Example
The following example uses the BinaryRead method to place the content of a request into a safe array.

<%
Dim binread
Dim bytecount
bytecount = Request.TotalBytes
binread = Request.BinaryRead(bytecount)
%>

DaveHope
04-13-2003, 11:07 AM
Shame...thanks for the Info :) Guess I've got some serious recoding to be done then. :rolleyes:

voxecho
01-06-2006, 05:54 PM
i know this thread is really old, but i was wondering if anyone can point me to where i can get information on how to READ the information in the SafeArray collected by request.BinaryRead

i can't get uBound to work, nor can in get [for each bleh in arr] so i am at a loss...

Echo

Bullschmidt
01-06-2006, 06:16 PM
does anyone have a solution or workaround to using BinaryRead after using Request.Form? Whenever I try to do anything like that I get errors similar to:

Request object error 'ASP 0206 : 80004005'

Cannot call BinaryRead

/admin/upload_class.asp, line 148

Cannot call BinaryRead after using Request.Form collection.


And here is a pure ASP (i.e. no components) resource for letting the user upload a file which is something that was unfortunately not built into ASP:

ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
http://aspzone.com/articles/160.aspx

The above free code has worked well for me and you can copy and paste the code sample which is white on gray (what were they thinking?) or just highlight it and it becomes black on white.

And most every uploading component or class including this class provides a syntax to be able to deal with regular form fields (as well as the uploaded files).

voxecho
01-06-2006, 08:03 PM
Thanks for that. but that's not the problem. I've already got a file upload solution in place, but i am trying to figure out how to read through a safearray or more accuratly how to read through the BinaryRead return. I've found something that seems to help (it uses an ADO recordset to convert from Binary to String) but what i am getting out of it is not at all what i expect.

what i am attempting to do is make something that even the graphics artist - who is a complete idoit but they have him doing 90% of the webstuff - can't flub up. :\ thanks again, though.