By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,812 Members | 875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,812 IT Pros & Developers. It's quick & easy.

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

P: n/a
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='multipart/form-data'? I'd also like it to parse the filename.

<form name='form1' method='POST' enctype='multipart/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="JavaScript" 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="aspinclude/upload.asp"-->
<script language="JavaScript" runat="server">
//Add record here (title1, filename from file1).
</script>

Thanks For Your Help,

Nate
Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On 5 Oct 2004 14:32:46 -0700, in comp.lang.javascript
na**********@cox.net (nate) wrote:
| 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='multipart/form-data'? I'd also like it to parse the filename.
|
| <form name='form1' method='POST' enctype='multipart/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.
You might try using a session variable.
| My ASP code looks like this:
|
| <script language="JavaScript" 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="aspinclude/upload.asp"-->
| <script language="JavaScript" runat="server">
| //Add record here (title1, filename from file1).
| </script>
|
| Thanks For Your Help,
|
| Nate


---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #2

P: n/a
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="JavaScript" runat="server">
gets executed. The ASP engine seems to run each code block in one page
asynchronously:
E.G.

1) <script language="JavaScript" runat="server">
1) <!--#include...--->
1) <script language="JavaScript" 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 <jn****@yourpantsbigpond.net.au> wrote in message news:<5f********************************@4ax.com>. ..
On 5 Oct 2004 14:32:46 -0700, in comp.lang.javascript
na**********@cox.net (nate) wrote:
| 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='multipart/form-data'? I'd also like it to parse the filename.
|
| <form name='form1' method='POST' enctype='multipart/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.


You might try using a session variable.
| My ASP code looks like this:
|
| <script language="JavaScript" 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="aspinclude/upload.asp"-->
| <script language="JavaScript" runat="server">
| //Add record here (title1, filename from file1).
| </script>
|
| Thanks For Your Help,
|
| Nate


---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------

Jul 23 '05 #3

P: n/a
On 6 Oct 2004 12:11:29 -0700, in comp.lang.javascript
na**********@cox.net (nate) wrote:
| 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="JavaScript" runat="server">
| gets executed. The ASP engine seems to run each code block in one page
| asynchronously:
| E.G.
|
| 1) <script language="JavaScript" runat="server">
| 1) <!--#include...--->
| 1) <script language="JavaScript" 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?


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.
---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #4

P: n/a
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" <jn****@yourpantsbigpond.net.au> wrote in message
news:f9********************************@4ax.com...
On 6 Oct 2004 12:11:29 -0700, in comp.lang.javascript
na**********@cox.net (nate) wrote:
| 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="JavaScript" runat="server">
| gets executed. The ASP engine seems to run each code block in one page
| asynchronously:
| E.G.
|
| 1) <script language="JavaScript" runat="server">
| 1) <!--#include...--->
| 1) <script language="JavaScript" 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?


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.
---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------

Jul 23 '05 #5

P: n/a
J.J.,

The 'module' I used is located at:
http://www.Planet-Source-Code.com/vb...=7093&lngWId=4
.. 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" <ph****@netvision.net.il> wrote in message news:<41******@news.012.net.il>...
Regarding the use of file upload modules. As I understand it asp files will
only run on Windows Servers.
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?
Server side javascript (which I've never used) would seem to be more
portable. Or php which runs basically cross platform.
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.
Is the OP relating to a Win environment?
As you will see when you download the script files, the 'OP'
(operation?) for the upload-part of the code uses the FileSystemObject
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 FileSystemObject or look on MSDN's
Web site for the documentation on this object.
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

Jul 23 '05 #6

P: n/a
na**********@cox.net (nate) wrote in message news:<46**************************@posting.google. com>...
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="JavaScript" runat="server">
gets executed. The ASP engine seems to run each code block in one page
asynchronously:
E.G.

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

...not...

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


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
http://www.aspfaq.com/show.asp?id=2045

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.
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.