472,951 Members | 2,228 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

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='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
6 6006
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chuck Amadi | last post by:
Has anyone got a simple python script that will parse a linux mbox and create a large file to view . Cheers Chu
5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
2
by: Cliff R. | last post by:
Hello, I have a form that has a few required fields and also an "agree to terms" checkbox that must be required. I have used Javascripts for both functions individually, but I need a little help...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
11
by: Marcelo | last post by:
Hi, I need to make a robot that fills forms. I already made that with php sites, but now I need that in a javascript pages site ( the robot can be php,asp, asp.net ), anyone knows how can I do...
1
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and...
1
by: theflyingminstrel | last post by:
Hi, I’m having some trouble with a Javascript code, and I was wondering if anyone can help: I am trying to build a price estimator that has multiple fields. I would like the first two fields to...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.