...

View Full Version : Why can't I access my form elements when using Pure ASP upload?



jaywhy13
08-21-2005, 10:53 PM
Is there no way I can access the other form elements when i'm uploading using pure asp?
I keep on getting this error everytime I attempt to access a form element.
Cannot access form element after doing binary read... or something to that effect

Bullschmidt
08-22-2005, 02:36 AM
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. And this does allow for accessing regular form fields. But as with any solution the syntax is a little different than a regular form with no file uploading:

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

"But what if an HTML form without the proper ENCTYPE posted to our upload code? We have no way of determining this prior to calling Request.BinaryRead. Once we do this, we can no longer access the Request.Form collection. We need to be able to handle application/x-www-form-urlencoded as well.

Lets examine this further..."

jaywhy13
08-22-2005, 04:38 AM
PLEASE tell me there's an easier way? :eek:
That looks awfully confusing, not to mention tedious and impossible.
And the legibility's discouraging

glenngv
08-22-2005, 05:36 AM
Which pure ASP Upload script are you using? I'm sure the author included a property to get the form data which is the counterpart of Request.Form. The property is probably named Form.


uploaderObject.Form("nameOfFormElement")

Check the documentation or demo of the script to see the available methods and properties of the uploader object.

Bullschmidt
08-22-2005, 05:41 AM
And the legibility's discouraging


True but the 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.

jaywhy13
08-22-2005, 05:41 AM
Which pure ASP Upload script are you using? I'm sure the author included a property to get the form data which is the counterpart of Request.Form. The property is probably named Form.


uploaderObject.Form("nameOfFormElement")

Check the documentation or demo of the script to see the available methods and properties of the uploader object.
I'm using the script over at
Jacob Gilley (http://www.asp101.com/articles/jacob/scriptupload.asp)
Didn't see anything about accessing other form elements

Bullschmidt
08-22-2005, 05:47 AM
OK with Jacob Gilley's code here's a code snippet in uploadexample.asp that shows examples about handling non-file fields such as fullname and saveto:

'******************************************
' Use [FileUploader object].Form to access
' additional form variables submitted with
' the file upload(s). (used below)
'******************************************
Response.Write "<b>Thank you for your upload " & Uploader.Form("fullname") & "</b><br>"

' Check if any files were uploaded
If Uploader.Files.Count = 0 Then
Response.Write "File(s) not uploaded."
Else
' Loop through the uploaded files
For Each File In Uploader.Files.Items

' Check where the user wants to save the file
If Uploader.Form("saveto") = "disk" Then

jaywhy13
08-22-2005, 05:48 AM
True but the 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.

It looks very confusing and I'm really not a pro where asp is concerned.. If I just have to throw in the inputs to a particular function i'll give it a shot but not if I have to do intense analysis.... I'm in the middle of workin on a project

jaywhy13
08-22-2005, 05:50 AM
OK with Jacob Gilley's code here's a code snippet in uploadexample.asp that mentions something about handling non-file fields:

'******************************************
' Use [FileUploader object].Form to access
' additional form variables submitted with
' the file upload(s). (used below)
'******************************************
Response.Write "<b>Thank you for your upload " & Uploader.Form("fullname") & "</b><br>"

' Check if any files were uploaded
If Uploader.Files.Count = 0 Then
Response.Write "File(s) not uploaded."
Else
' Loop through the uploaded files
For Each File In Uploader.Files.Items

' Check where the user wants to save the file
If Uploader.Form("saveto") = "disk" Then

My deepest gratitude... I forgot to check back the examples

Bullschmidt
08-22-2005, 05:52 AM
You're welcome and hope you get it to work well in your project. And of course don't forget to give any needed permissions to folders you'll be uploading files to.

And can increase the timeout for the particular page as you see fit:
' Script timeout in seconds for this page.
' (60 x 60 = 1 hour.)
Server.ScriptTimeout = 60 * 60



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum