JavaScript script to parse text fields from multipart/form-data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nate

    #1

    JavaScript script to parse text fields from multipart/form-data

    Hello,

    Does anyone know where I can find an ASP server side script written in
    JavaScript to parse text fields from a form method='POST' using
    enctype='multip art/form-data'? I'd also like it to parse the filename.

    <form name='form1' method='POST' enctype='multip art/form-data'
    action='sub.asp '>
    <input type='text' name='title1' value='value1'>
    <input type='file' name='file1'>
    </form>

    I found a great ASP VBScript for uploading files, but the rest of my
    Web site is coded in ASP using JavaScript and I can't figure out a way
    to immediately pass the text fields already parsed from server side
    VBScript to server side JavaScript.

    My ASP code looks like this:

    <script language="JavaS cript" runat="server">
    //I would like to add JavaScript to parse the text field and
    filename of file1 here.
    </script>
    <!--The 3rd party document below parses all fields from the message
    content and uploads any file fields it encounters.--->
    <!--#include file="aspinclud e/upload.asp"-->
    <script language="JavaS cript" runat="server">
    //Add record here (title1, filename from file1).
    </script>

    Thanks For Your Help,

    Nate
  • Jeff North

    #2
    Re: JavaScript script to parse text fields from multipart/form-data

    On 5 Oct 2004 14:32:46 -0700, in comp.lang.javas cript
    nathandeneau@co x.net (nate) wrote:
    [color=blue]
    >| Hello,
    >|
    >| Does anyone know where I can find an ASP server side script written in
    >| JavaScript to parse text fields from a form method='POST' using
    >| enctype='multip art/form-data'? I'd also like it to parse the filename.
    >|
    >| <form name='form1' method='POST' enctype='multip art/form-data'
    >| action='sub.asp '>
    >| <input type='text' name='title1' value='value1'>
    >| <input type='file' name='file1'>
    >| </form>
    >|
    >| I found a great ASP VBScript for uploading files, but the rest of my
    >| Web site is coded in ASP using JavaScript and I can't figure out a way
    >| to immediately pass the text fields already parsed from server side
    >| VBScript to server side JavaScript.[/color]

    You might try using a session variable.
    [color=blue]
    >| My ASP code looks like this:
    >|
    >| <script language="JavaS cript" runat="server">
    >| //I would like to add JavaScript to parse the text field and
    >| filename of file1 here.
    >| </script>
    >| <!--The 3rd party document below parses all fields from the message
    >| content and uploads any file fields it encounters.--->
    >| <!--#include file="aspinclud e/upload.asp"-->
    >| <script language="JavaS cript" runat="server">
    >| //Add record here (title1, filename from file1).
    >| </script>
    >|
    >| Thanks For Your Help,
    >|
    >| Nate[/color]

    ---------------------------------------------------------------
    jnorth@yourpant sbigpond.net.au : Remove your pants to reply
    ---------------------------------------------------------------

    Comment

    • nate

      #3
      Re: JavaScript script to parse text fields from multipart/form-data

      Jeff,

      Thanks for your reply.

      I already tried using Session and Application variables. This doesn't
      work because the Session (and Application) variables are not updated
      by the time the second <script language="JavaS cript" runat="server">
      gets executed. The ASP engine seems to run each code block in one page
      asynchronously:
      E.G.

      1) <script language="JavaS cript" runat="server">
      1) <!--#include...--->
      1) <script language="JavaS cript" runat="server">

      ....not...

      1) <step>
      2) <step>
      3) <step>

      The Session (and Application) variables are only updated WHEN I
      refresh the page.

      I never solved this dilema, but I did come up with a work-around. I
      just coded the whole page in VBScript (a pain-in-the-butt for me since
      I mostly use JavaScript) and everything is working now. It seems silly
      to me that you can do so much using JavaScript, and then suddenly hit
      a road block (e.g. I can't upload a file to the server using
      JavaScript). Maybe the next guy will read this and not spend 5 hours
      trying to get the code to work using JavaScript?

      Thanks,

      Nate

      Jeff North <jnorth@yourpan tsbigpond.net.a u> wrote in message news:<5fk7m0hvu ehflmgp74pjh5pm f48uee7ano@4ax. com>...[color=blue]
      > On 5 Oct 2004 14:32:46 -0700, in comp.lang.javas cript
      > nathandeneau@co x.net (nate) wrote:
      >[color=green]
      > >| Hello,
      > >|
      > >| Does anyone know where I can find an ASP server side script written in
      > >| JavaScript to parse text fields from a form method='POST' using
      > >| enctype='multip art/form-data'? I'd also like it to parse the filename.
      > >|
      > >| <form name='form1' method='POST' enctype='multip art/form-data'
      > >| action='sub.asp '>
      > >| <input type='text' name='title1' value='value1'>
      > >| <input type='file' name='file1'>
      > >| </form>
      > >|
      > >| I found a great ASP VBScript for uploading files, but the rest of my
      > >| Web site is coded in ASP using JavaScript and I can't figure out a way
      > >| to immediately pass the text fields already parsed from server side
      > >| VBScript to server side JavaScript.[/color]
      >
      > You might try using a session variable.
      >[color=green]
      > >| My ASP code looks like this:
      > >|
      > >| <script language="JavaS cript" runat="server">
      > >| //I would like to add JavaScript to parse the text field and
      > >| filename of file1 here.
      > >| </script>
      > >| <!--The 3rd party document below parses all fields from the message
      > >| content and uploads any file fields it encounters.--->
      > >| <!--#include file="aspinclud e/upload.asp"-->
      > >| <script language="JavaS cript" runat="server">
      > >| //Add record here (title1, filename from file1).
      > >| </script>
      > >|
      > >| Thanks For Your Help,
      > >|
      > >| Nate[/color]
      >
      > ---------------------------------------------------------------
      > jnorth@yourpant sbigpond.net.au : Remove your pants to reply
      > ---------------------------------------------------------------[/color]

      Comment

      • Jeff North

        #4
        Re: JavaScript script to parse text fields from multipart/form-data

        On 6 Oct 2004 12:11:29 -0700, in comp.lang.javas cript
        nathandeneau@co x.net (nate) wrote:
        [color=blue]
        >| Jeff,
        >|
        >| Thanks for your reply.
        >|
        >| I already tried using Session and Application variables. This doesn't
        >| work because the Session (and Application) variables are not updated
        >| by the time the second <script language="JavaS cript" runat="server">
        >| gets executed. The ASP engine seems to run each code block in one page
        >| asynchronously:
        >| E.G.
        >|
        >| 1) <script language="JavaS cript" runat="server">
        >| 1) <!--#include...--->
        >| 1) <script language="JavaS cript" runat="server">
        >|
        >| ...not...
        >|
        >| 1) <step>
        >| 2) <step>
        >| 3) <step>
        >|
        >| The Session (and Application) variables are only updated WHEN I
        >| refresh the page.
        >|
        >| I never solved this dilema, but I did come up with a work-around. I
        >| just coded the whole page in VBScript (a pain-in-the-butt for me since
        >| I mostly use JavaScript) and everything is working now. It seems silly
        >| to me that you can do so much using JavaScript, and then suddenly hit
        >| a road block (e.g. I can't upload a file to the server using
        >| JavaScript). Maybe the next guy will read this and not spend 5 hours
        >| trying to get the code to work using JavaScript?[/color]

        I feel your pain as I had the same problem not so long ago.
        I use Lewis Moten's Upload without com scripts (writtin in VBScript)
        but my pages are written in JScript.

        The way I worked around this was to (I coded this for the company's
        intranet so I know the set up was ok).
        a. call the popup window that selects the file - no changes here
        b. the second window that performs the actual upload I changed to use
        a cookie to set the filename + the getElementById to so the name of
        the parent page.
        ---------------------------------------------------------------
        jnorth@yourpant sbigpond.net.au : Remove your pants to reply
        ---------------------------------------------------------------

        Comment

        • J. J. Cale

          #5
          Re: JavaScript script to parse text fields from multipart/form-data

          Regarding the use of file upload modules. As I understand it asp files will
          only run on Windows Servers. Server side javascript (which I've never used)
          would seem to be more portable. Or php which runs basically cross platform.
          Is the OP relating to a Win environment? Where can I get a file upload
          module written in VB that will work without a dll? BTW I tried the link to
          Lewis Motens page but my browser (IE5) throws an error (XML something or
          other) and I can't get to the download page. TIA
          Jimbo
          "Jeff North" <jnorth@yourpan tsbigpond.net.a u> wrote in message
          news:f9r9m0l1vk knlsiucl3marod4 m7gl6g616@4ax.c om...[color=blue]
          > On 6 Oct 2004 12:11:29 -0700, in comp.lang.javas cript
          > nathandeneau@co x.net (nate) wrote:
          >[color=green]
          > >| Jeff,
          > >|
          > >| Thanks for your reply.
          > >|
          > >| I already tried using Session and Application variables. This doesn't
          > >| work because the Session (and Application) variables are not updated
          > >| by the time the second <script language="JavaS cript" runat="server">
          > >| gets executed. The ASP engine seems to run each code block in one page
          > >| asynchronously:
          > >| E.G.
          > >|
          > >| 1) <script language="JavaS cript" runat="server">
          > >| 1) <!--#include...--->
          > >| 1) <script language="JavaS cript" runat="server">
          > >|
          > >| ...not...
          > >|
          > >| 1) <step>
          > >| 2) <step>
          > >| 3) <step>
          > >|
          > >| The Session (and Application) variables are only updated WHEN I
          > >| refresh the page.
          > >|
          > >| I never solved this dilema, but I did come up with a work-around. I
          > >| just coded the whole page in VBScript (a pain-in-the-butt for me since
          > >| I mostly use JavaScript) and everything is working now. It seems silly
          > >| to me that you can do so much using JavaScript, and then suddenly hit
          > >| a road block (e.g. I can't upload a file to the server using
          > >| JavaScript). Maybe the next guy will read this and not spend 5 hours
          > >| trying to get the code to work using JavaScript?[/color]
          >
          > I feel your pain as I had the same problem not so long ago.
          > I use Lewis Moten's Upload without com scripts (writtin in VBScript)
          > but my pages are written in JScript.
          >
          > The way I worked around this was to (I coded this for the company's
          > intranet so I know the set up was ok).
          > a. call the popup window that selects the file - no changes here
          > b. the second window that performs the actual upload I changed to use
          > a cookie to set the filename + the getElementById to so the name of
          > the parent page.
          > ---------------------------------------------------------------
          > jnorth@yourpant sbigpond.net.au : Remove your pants to reply
          > ---------------------------------------------------------------[/color]


          Comment

          • nate

            #6
            Re: JavaScript script to parse text fields from multipart/form-data

            J.J.,

            The 'module' I used is located at:

            .. It works great. Don't forget to use the faster version (you'll see
            after you download the files). The script uploads your file and parses
            all form fields. Make sure you have write permissions in the directory
            you run the scripts. Tweaking the code to my specifications was easy
            (it took about an hour and I don't code ASP pages in VBScript much -
            mostly in JavaScript).

            P.S. I inserted a few additional comments below.

            Good Luck!

            Nate...

            "J. J. Cale" <photom@netvisi on.net.il> wrote in message news:<41681a72@ news.012.net.il >...[color=blue]
            > Regarding the use of file upload modules. As I understand it asp files will
            > only run on Windows Servers.[/color]

            The only way I've ever used ASP (Active Server Page) scripts is with
            Windows 2000 - IIS (Internet Information Services). I think you can
            also use ASP scripts with whatever dynamic web server optionally came
            with Windows NT 4?
            [color=blue]
            > Server side javascript (which I've never used) would seem to be more
            > portable. Or php which runs basically cross platform.[/color]

            I'm not sure what you mean by 'more protable'? Client-side and
            Server-side VBScript and JavaScript scripts can easily be copied and
            pasted into your .asp, .htm, and .html files, but you could not do
            something like say, copy Server-side ASP scripts into your PHP (CGI)
            dynamic Web server.
            [color=blue]
            > Is the OP relating to a Win environment?[/color]

            As you will see when you download the script files, the 'OP'
            (operation?) for the upload-part of the code uses the FileSystemObjec t
            to upload a file to a Windows environment. I'm not sure if you can
            specify a location other than a Windows local path, such as a Unix
            path or a network share? Google the FileSystemObjec t or look on MSDN's
            Web site for the documentation on this object.
            [color=blue]
            > Where can I get a file upload
            > module written in VB that will work without a dll? BTW I tried the link to
            > Lewis Motens page but my browser (IE5) throws an error (XML something or
            > other) and I can't get to the download page. TIA
            > Jimbo[/color]

            Comment

            • MikeT

              #7
              Re: JavaScript script to parse text fields from multipart/form-data

              nathandeneau@co x.net (nate) wrote in message news:<4630acfb. 0410061111.59ac 6358@posting.go ogle.com>...[color=blue]
              > Jeff,
              >
              > Thanks for your reply.
              >
              > I already tried using Session and Application variables. This doesn't
              > work because the Session (and Application) variables are not updated
              > by the time the second <script language="JavaS cript" runat="server">
              > gets executed. The ASP engine seems to run each code block in one page
              > asynchronously:
              > E.G.
              >
              > 1) <script language="JavaS cript" runat="server">
              > 1) <!--#include...--->
              > 1) <script language="JavaS cript" runat="server">
              >
              > ...not...
              >
              > 1) <step>
              > 2) <step>
              > 3) <step>
              >[/color]

              Your problem is mixing languages in one ASP page - the execution order
              is not obvious or the order the scripts appear in the file. It's one
              of the petty niggles of ASP - see


              Once you understand how the ASP engine works, mixing languages is not
              a problem. I've got one page that (for various reasons) has VBscript,
              JScript and Perl all running together and once I'd read that article,
              all was well.

              Comment

              Working...