469,270 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

ASP Issue with form that posts data to databse and uploads image file

Hello,

We have a small program that allows licensees around the world to submit requests to our home office. They complete the request on an ASP form (with an HTM page) over a https connection. One of the required fields is for upload. Starting in the last week, the page has begun to "misbehave". I was able to recreate the problem and it looks like the form is not able to pick up the "request.form" statements. I've done a little research and it appears that it might be the tag "enctype='multipart/form-data' in conflict with the attempt to use "request.form" Two main questions, 1) what should I use instead of request.form and 2) why would it start complaining all of a sudden. Also, the error doesn't occur with every request, it is sporadic. Also, should note that we are using ASPSmartUpload and 2 months ago I needed to edit the IIS settings to increase file size - but I'm sure this is adifferent issue.

Any suggestions would be extremely helpful!

Julie
Sep 6 '07 #1
5 1526
markrawlingson
346 Expert 100+
Hmmm,

I had a similar problem a few months back. We had a registration form (didn't include an upload field) that clients could fill out to register for our product. For some reason, about 50-60% of the time.. the form submissions would generate random invalid characters even though we were preventing them and cleaning them out using client side javascript and asp - all the potential clients we spoke to regarding the problem denied entering these themselves - so the information in the request.form object got altered somehow. You'd have the first name field be entered as "Joe" and returned in the request.form object as j%%%o%20%20%20.

We never did figure it out, though that is an excellent point about the enctype - I'll take a look at it again (it's still somewhere on our server) and check to see if it uses an enctype - i'll get back to you.
Sep 6 '07 #2
jhardman
3,406 Expert 2GB
Hi Julie,

1) instead of 'request.form("myTextInput")' you can just say 'request("myTextInput")'. The ".form" is just supposed to specify which part of the request object had the input, and it isn't really necessary unless you think you have a cookie, a querystring, or a serverVariable with the same name. A good way to test what info any page receives is this:
Expand|Select|Wrap|Line Numbers
  1. response.write "Form inputs:<br>" & vbNewLine
  2. for each x in request.form
  3.    response.write x & request.form(x) & "<br>" & vbNewLine
  4. next
  5.  
  6. response.write "Querystring inputs:<br>" & vbNewLine
  7. for each x in request.querystring
  8.    response.write x & request.querystring(x) & "<br>" & vbNewLine
  9. next
  10.  
  11. response.write "Cookies:<br>" & vbNewLine
  12. for each x in request.cookies
  13.    response.write x & request.cookies(x) & "<br>" & vbNewLine
  14. next
  15.  
  16. response.write "Server variables:<br>" & vbNewLine
  17. for each x in request.serverVariables
  18.    response.write x & request.serverVariables(x) & "<br>" & vbNewLine
  19. next
This will print all the info sent to the page (except that file inputs will only show the file name if printed like this)

2- I don'[t know why this would all of a sudden cause an error. You definitely need the enctype as you stated above in order to send both files and text inputs. Is the data sent to ASPSmartUpload first, and then sent on again to another ASP page on your server?

Jared
Sep 6 '07 #3
Hi Julie,

1) instead of 'request.form("myTextInput")' you can just say 'request("myTextInput")'. The ".form" is just supposed to specify which part of the request object had the input, and it isn't really necessary unless you think you have a cookie, a querystring, or a serverVariable with the same name. A good way to test what info any page receives is this:
Expand|Select|Wrap|Line Numbers
  1. response.write "Form inputs:<br>" & vbNewLine
  2. for each x in request.form
  3.    response.write x & request.form(x) & "<br>" & vbNewLine
  4. next
  5.  
  6. response.write "Querystring inputs:<br>" & vbNewLine
  7. for each x in request.querystring
  8.    response.write x & request.querystring(x) & "<br>" & vbNewLine
  9. next
  10.  
  11. response.write "Cookies:<br>" & vbNewLine
  12. for each x in request.cookies
  13.    response.write x & request.cookies(x) & "<br>" & vbNewLine
  14. next
  15.  
  16. response.write "Server variables:<br>" & vbNewLine
  17. for each x in request.serverVariables
  18.    response.write x & request.serverVariables(x) & "<br>" & vbNewLine
  19. next
This will print all the info sent to the page (except that file inputs will only show the file name if printed like this)

2- I don'[t know why this would all of a sudden cause an error. You definitely need the enctype as you stated above in order to send both files and text inputs. Is the data sent to ASPSmartUpload first, and then sent on again to another ASP page on your server?

Jared

Hi Jared,

Thanks for your reply. Without a doubt, issues that happen "intermittently" are the most frustrating to troubleshoot!

I changed Request.form to just request, but got the same results. I added your code and as expected all the .form elements are blank.

The page takes a number of the form elements and posts them to a database via a stored procedure, then the upload occurs

Thanks,

Julie
Sep 6 '07 #4
jhardman
3,406 Expert 2GB
Hi Jared,

Thanks for your reply. Without a doubt, issues that happen "intermittently" are the most frustrating to troubleshoot!

I changed Request.form to just request, but got the same results. I added your code and as expected all the .form elements are blank.

The page takes a number of the form elements and posts them to a database via a stored procedure, then the upload occurs

Thanks,

Julie
When you say blank, do you mean nothing is there like this:
Expand|Select|Wrap|Line Numbers
  1. Form Inputs:
  2. myTextInput:
  3. myfileInput:
  4. mySelect:
  5. submit:
  6. Querystring inputs:
or like this:
Expand|Select|Wrap|Line Numbers
  1. Form Inputs:
  2. Querystring inputs:
?

I think the problem is that you are going from one page to another on some conditions, perhaps depending on the size of the file (there is a limit to the size of files that can be imported through HTML forms regardless of server settings. If the file is larger, good uploaders can circumvent this restriction, and their methods are pretty complicated. It is my guess that ASPSmartUpload is sending data to multiple scripts) and somehow the form data isn't making it all the way through.

If the form data is first accessed somewhere else, then I would do this:
-The first time you access the data (right before you store it in the db), save all of the form data as session-level variables (this won't work for the file, unfortunately) like this:
Expand|Select|Wrap|Line Numbers
  1. for each x in request.form
  2.    session(x) = request.form(x)
  3. next
-then when you need it later, ask for session("whatever") instead of request("whatever"), its session name will be the same as its request name. Let me know if that works.

Jared
Sep 6 '07 #5
When you say blank, do you mean nothing is there like this:
Expand|Select|Wrap|Line Numbers
  1. Form Inputs:
  2. myTextInput:
  3. myfileInput:
  4. mySelect:
  5. submit:
  6. Querystring inputs:
or like this:
Expand|Select|Wrap|Line Numbers
  1. Form Inputs:
  2. Querystring inputs:
?

I think the problem is that you are going from one page to another on some conditions, perhaps depending on the size of the file (there is a limit to the size of files that can be imported through HTML forms regardless of server settings. If the file is larger, good uploaders can circumvent this restriction, and their methods are pretty complicated. It is my guess that ASPSmartUpload is sending data to multiple scripts) and somehow the form data isn't making it all the way through.

If the form data is first accessed somewhere else, then I would do this:
-The first time you access the data (right before you store it in the db), save all of the form data as session-level variables (this won't work for the file, unfortunately) like this:
Expand|Select|Wrap|Line Numbers
  1. for each x in request.form
  2.    session(x) = request.form(x)
  3. next
-then when you need it later, ask for session("whatever") instead of request("whatever"), its session name will be the same as its request name. Let me know if that works.

Jared
Jared,

Thanks again for your help. After a lot of research, we discovered that at some point in the past, somebody started the work to move to another upload product. For some reason the half-written code that has been there for awhile started to interefere with the page's processing. I ended up commenting out the offensive code and we are back in business.

I truly apprecuate the time you took to help me out!

Happy Monday!

Julie
Sep 10 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by sentinel | last post: by
2 posts views Thread by Philip D Heady | last post: by
4 posts views Thread by Alex Sibilev | last post: by
6 posts views Thread by Emmanuel Petit | last post: by
44 posts views Thread by badvoc | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.