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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JCCDEVEL
    New Member
    • Jun 2007
    • 15

    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.fo rm" statements. I've done a little research and it appears that it might be the tag "enctype='multi part/form-data' in conflict with the attempt to use "request.fo rm" 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
  • markrawlingson
    Recognized Expert Contributor
    • Aug 2007
    • 346

    #2
    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.

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      Hi Julie,

      1) instead of 'request.form(" myTextInput")' you can just say 'request("myTex tInput")'. 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:
      [code=asp]response.write "Form inputs:<br>" & vbNewLine
      for each x in request.form
      response.write x & request.form(x) & "<br>" & vbNewLine
      next

      response.write "Querystrin g inputs:<br>" & vbNewLine
      for each x in request.queryst ring
      response.write x & request.queryst ring(x) & "<br>" & vbNewLine
      next

      response.write "Cookies:<b r>" & vbNewLine
      for each x in request.cookies
      response.write x & request.cookies (x) & "<br>" & vbNewLine
      next

      response.write "Server variables:<br>" & vbNewLine
      for each x in request.serverV ariables
      response.write x & request.serverV ariables(x) & "<br>" & vbNewLine
      next[/code]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

      Comment

      • JCCDEVEL
        New Member
        • Jun 2007
        • 15

        #4
        Originally posted by jhardman
        Hi Julie,

        1) instead of 'request.form(" myTextInput")' you can just say 'request("myTex tInput")'. 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:
        [code=asp]response.write "Form inputs:<br>" & vbNewLine
        for each x in request.form
        response.write x & request.form(x) & "<br>" & vbNewLine
        next

        response.write "Querystrin g inputs:<br>" & vbNewLine
        for each x in request.queryst ring
        response.write x & request.queryst ring(x) & "<br>" & vbNewLine
        next

        response.write "Cookies:<b r>" & vbNewLine
        for each x in request.cookies
        response.write x & request.cookies (x) & "<br>" & vbNewLine
        next

        response.write "Server variables:<br>" & vbNewLine
        for each x in request.serverV ariables
        response.write x & request.serverV ariables(x) & "<br>" & vbNewLine
        next[/code]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

        Comment

        • jhardman
          Recognized Expert Specialist
          • Jan 2007
          • 3405

          #5
          Originally posted by JCCDEVEL
          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:
          Code:
          Form Inputs:
          myTextInput:
          myfileInput:
          mySelect:
          submit:
          Querystring inputs:
          or like this:
          Code:
          Form Inputs:
          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:
          [code=asp]for each x in request.form
          session(x) = request.form(x)
          next[/code]-then when you need it later, ask for session("whatev er") instead of request("whatev er"), its session name will be the same as its request name. Let me know if that works.

          Jared

          Comment

          • JCCDEVEL
            New Member
            • Jun 2007
            • 15

            #6
            Originally posted by jhardman
            When you say blank, do you mean nothing is there like this:
            Code:
            Form Inputs:
            myTextInput:
            myfileInput:
            mySelect:
            submit:
            Querystring inputs:
            or like this:
            Code:
            Form Inputs:
            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:
            [code=asp]for each x in request.form
            session(x) = request.form(x)
            next[/code]-then when you need it later, ask for session("whatev er") instead of request("whatev er"), 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

            Comment

            Working...