473,394 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Submit Formwith AJAX Using ENCTYPE="multipart/form-data"

Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multipart/form-data" (error 500).
Without ENCTYPE="multipart/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.

Here is a part of xmlhttp request where I set header:
....
this.req.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(arguments[3]);

Mar 20 '07 #1
4 32474
On Mar 19, 11:07 pm, vunet...@gmail.com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multipart/form-data" (error 500).
Without ENCTYPE="multipart/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.

Here is a part of xmlhttp request where I set header:
...
this.req.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(arguments[3]);
Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.

Mar 20 '07 #2
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.comwrote:
On Mar 19, 11:07 pm, vunet...@gmail.com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multipart/form-data" (error 500).
Without ENCTYPE="multipart/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.
Here is a part of xmlhttp request where I set header:
...
this.req.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(arguments[3]);

Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.
If I submit my form the normal html way, with ENCTYPE="multipart/form-
data", everything works well. But I need the equivalent in AJAX. I do
not understand how iframes may be related to my problem. I want to do
a simple AJAX form submission using ENCTYPE="multipart/form-data"...
Thanks.

Mar 20 '07 #3
On Mar 20, 8:42 am, vunet...@gmail.com wrote:
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.comwrote:
On Mar 19, 11:07 pm, vunet...@gmail.com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multipart/form-data" (error 500).
Without ENCTYPE="multipart/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.
Here is a part of xmlhttp request where I set header:
...
this.req.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(arguments[3]);
Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.

If I submit my form the normal html way, with ENCTYPE="multipart/form-
data", everything works well. But I need the equivalent in AJAX. I do
not understand how iframes may be related to my problem. I want to do
a simple AJAX form submission using ENCTYPE="multipart/form-data"...
Thanks.
Okay, you can't.

Mar 20 '07 #4
On Mar 20, 10:00 am, "Tom Cole" <tco...@gmail.comwrote:
On Mar 20, 8:42 am, vunet...@gmail.com wrote:
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.comwrote:
On Mar 19, 11:07 pm, vunet...@gmail.com wrote:
Hi all,
I am converting my app to AJAX-based. I have a form that submits some
data including images. When I use AJAX XmlHttpRequest I am unable to
submit the form with ENCTYPE="multipart/form-data" (error 500).
Without ENCTYPE="multipart/form-data", everything goes well. I think
there is a header I must use in addition, but I cannot seem to find a
good solution. Can you suggest? Thank you.
Here is a part of xmlhttp request where I set header:
...
this.req.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(arguments[3]);
Well there are more issues than that...You can set your multipart/form-
data header all day long, but your javascript code is still not going
to have access to the file data, only the file name. There are other
methods for this (like hidden iframes) that you should investigate if
your goal is not to refresh the view of the current page.
If I submit my form the normal html way, with ENCTYPE="multipart/form-
data", everything works well. But I need the equivalent in AJAX. I do
not understand how iframes may be related to my problem. I want to do
a simple AJAX form submission using ENCTYPE="multipart/form-data"...
Thanks.

Okay, you can't.
Really? Oh, so you gave me a hint that if I use a hidden iframe to
submit data the normal html way, then it is a solution for me... isn't
it?

Mar 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
2
by: Alex | last post by:
Hello, I use the following script inside a page. My page contains : 1 FORM, Some Hidden fields, and one line of JAVASCRIPT in order to instantly post the Form. The problem is that under...
2
by: Mr.Clean | last post by:
If I have an Input of type image, it is not listed in the Forms elements when walking to DOM using MSHTML. Is this expected behaviour and how would I get the image input to submit the form NOT...
5
by: Jeff | last post by:
Visual Studio 2003 DotNet framework 1.1 Windows 2000 Pro I create two pages in an Asp.net application, one is html page with a form in it: .... <form id="testForm" method="post"...
23
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target...
1
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL:...
5
by: Heofz | last post by:
Hey all, I've been banging my head against a brick wall on this one for the last 12 hours, and the time has come for me to give up and consult the gurus on this one. The below URL contains a...
11
by: Jonathan Wood | last post by:
Can anyone point me to any good resources on adding AJAX to a page once the page has already been created? I know VS2008 has options to add AJAX pages, but I didn't select those options when the...
14
by: white lightning | last post by:
How to have <select onchange="this.form.submit()"and also a Submit button on one form? I have something like this: <form action="<?php $_SERVER; ?>" method="post"...
1
by: aivanov | last post by:
Hi, I am trying to figiure out why Ajax pop-up window not works with radio button (<input type="radio" onclick="submit()" >). But it works with input type=submit value=value="<?php echo...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.