473,735 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 23 '05 #1
6 6104
On 5 Oct 2004 14:32:46 -0700, in comp.lang.javas cript
na**********@co x.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='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.
You might try using a session variable.
| 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


---------------------------------------------------------------
jn****@yourpant sbigpond.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="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 <jn****@yourpan tsbigpond.net.a u> wrote in message news:<5f******* *************** **********@4ax. com>...
On 5 Oct 2004 14:32:46 -0700, in comp.lang.javas cript
na**********@co x.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='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.


You might try using a session variable.
| 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


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

Jul 23 '05 #3
On 6 Oct 2004 12:11:29 -0700, in comp.lang.javas cript
na**********@co x.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="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?


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****@yourpant sbigpond.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****@yourpan tsbigpond.net.a u> wrote in message
news:f9******** *************** *********@4ax.c om...
On 6 Oct 2004 12:11:29 -0700, in comp.lang.javas cript
na**********@co x.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="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?


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****@yourpant sbigpond.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****@netvisi on.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 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.
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**********@co x.net (nate) wrote in message news:<46******* *************** ****@posting.go ogle.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="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>


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
8862
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
2692
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 function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
2
1864
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 in combining them. Can someone help me combine these two scripts so they both work on the same page, with <FORM METHOD=POST onSubmit="return checkrequired(this)" etc., checking for required fields and making sure the agree-to-terms button is...
19
6929
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 JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
136
9430
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
8
3674
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
11
2168
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 it? or somewhere I can find more info? Thanks! Marcelo
1
6891
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 grandtotal the costs ready for the selected items to be inserted back to the database. I did something like this before with Checkboxes, but Radio button have to be named the same to maintain their groupings.
1
1848
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 have a price value based on a quantity price, so for example 1-10 qantity equals $30, 20-30 quantity equals $40 in the “Total” field). The rest of the fields in the following code work as intended whereas they just add based on the price to the right....
2
9037
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 figure this problem out. Any suggestions? thanks Joel
0
9466
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9202
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8202
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3278
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2191
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.