PDA

View Full Version : error when uploading image


CdnGal
03-29-2003, 03:07 AM
Hi, all..
(newbie)

Can someone please translate this into English for me. Here's the scenario...I have some .asp pages where basically the user logs in....then once he's "in"...he is presented with a list of products and information from a database. He can then click on Add, delete, edit etc...so when I click on ADD....a blank form is presented to me....I filled it out...clicked on browse to find an image to upload...then I get the error below. All of this was working just fine, UNTIL we had to now add in a way for the user to upload an image. I've modified the code to do this (well, tried to)..and here's where I'm stuck now.

The file Authenticate is used to have the user log in....not sure why it says LIne 27, as line 27 in the code says: Dim username : username = Request("Username")

Incidentally, when I modified my pages to now incorporate uploading images...I did not touch anything in authenticating the user at all. I left that page as it was.

Thanks


Error Type:
Request object, ASP 0208 (0x80004005)
Cannot use the generic Request collection after calling BinaryRead.
/StudentWebs/PTetz/MCSP255/final/_admin/includes/Authenticate.vbs, line 27

and now it seems I have other issues as well....while I was posting the above message..I changed a "Request.Form to Multipart.Form...and now I don't even GET to that point above...

I get the message: Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/StudentWebs/PTetz/MCSP255/final/_admin/products/editproducts.asp, line 43

which line 43 says: if (Multipart.Form("catalogID").Item <> "") then
...etc...

would it help if I just attached the applicable files?

Geez.....I'm pain aren't I?;)

dominicall
03-29-2003, 06:43 AM
Hi

The first problem - you can't call Request after doing a binary read. The error is being thrown on line 27 because you're trying to request the username - after the binary read I'm assuming as we don't have the rest of your code. To get round this I would suggest changing the way your authentication works.

Unless it's critical that you check the username and password against the database on every single page then you only need to make the authentication call when a user first logs in. Doing so will put a lot of extra load on your site that's really not necessary. The better process is this...

1. User enters username and password.
2. Checked against database
....a) If not OK bounce back to log in page with an error
....b) If OK then store userid, username and password in session variables.
3. On each subsequent page all you then need to do is to check the presence and contents of the session variables, as follows:If Session.Contents("username") <> "" OR Not(IsNull(Session.Contents("username")) Then
Dim username: username = Session.Contents("username")
Else
Response.Redirect "notloggedin.asp"
End IfYou'll remove a lot of processing overhead from both the web layer and data layer of the site which will improve the overall efficiency of the site - and you won't get the Request error.

Have a look on the web about using session variables for authentication - there's lot's of good tutorials.

Second Problem. So far as I know there's no such thing as MultiPart.Form (unless M$ slipped it in and didn't tell anyone).

The first thing if you're trying to upload files is to make absolutely sure that in your form definition you include enctype as follows:<form name="someform" method="post" action="apage.asp" enctype="multipart/form-data">If you don't then the page processing the form won't recognise the fact that you're trying to upload a file.

I would suggest the best thing for the upload is to use a COM component. My preference is ASPUpload from Persits software (http://www.aspupload.com) but there are plenty of others around.

Remember though, once you've called the upload, however you're doing it (through FSO or component) you can't call Request.Form to get any of the other form data.

Hope that helps.

dominicall :D

CdnGal
03-30-2003, 02:13 AM
Hm....I thought I was confused BEFORE...haha

Thanks for the help....I will look into it further. We did a class the other day which was very similar and I got that one working but THIS particular assignment is different in two ways...one, is the authentication, and the other difference is that the user can select an item to edit, or delete...or add an item. The one I got working the other day only has ADD as an option, not edit and o authentication...so the pages are slightly different.

But thank you for the help. I really appreciate it!