473,671 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submit Formwith AJAX Using ENCTYPE="multip art/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="multip art/form-data" (error 500).
Without ENCTYPE="multip art/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.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[3]);

Mar 20 '07 #1
4 32520
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="multip art/form-data" (error 500).
Without ENCTYPE="multip art/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.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[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.c omwrote:
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="multip art/form-data" (error 500).
Without ENCTYPE="multip art/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.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[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="multip art/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="multip art/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.c omwrote:
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="multip art/form-data" (error 500).
Without ENCTYPE="multip art/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.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[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="multip art/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="multip art/form-data"...
Thanks.
Okay, you can't.

Mar 20 '07 #4
On Mar 20, 10:00 am, "Tom Cole" <tco...@gmail.c omwrote:
On Mar 20, 8:42 am, vunet...@gmail. com wrote:
On Mar 20, 9:33 am, "Tom Cole" <tco...@gmail.c omwrote:
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="multip art/form-data" (error 500).
Without ENCTYPE="multip art/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.setReq uestHeader("Con tent-Type", "applicatio n/x-www-form-
urlencoded; charset=UTF-8");
this.req.send(a rguments[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="multip art/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="multip art/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
4190
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 in IE as well as FireFox. This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL 4.1.8 and it works fine. The problem server is a Win2k server, IIS5, PHP 5.0.4, mySQL 4.1.11.
2
16345
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 FIREFOX, the JAVASCRIPT line don't seems to be correct, because FIREFOX does'nt post the Form... But my javascript line looks correct to me... Below is the Script; thanks for your Help in advance.
2
4228
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 using document.form.submit?
5
4577
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" action="test.aspx" runat="server"> <input type="hidden" id="hiddenTest" value="hello, world"> <input type="submit" id="btnSubmit" value="submit">
23
3627
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 page I don't get any session variable values! BTW, I used a relative location in the Location header, not an absolute URL. The behavior looks like it started another session, but it should not have. Ideas? TIA,
1
8017
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: http://(address.of.my.webcam):port/LiveView.html and
5
6407
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 login page, you can test it using the details User: marco Pass: polo This seems to work PERFECTLY in opera, and it works in firefox but ONLY if I have firebug enabled. I don't care about IE for now, I'll sort that out later.
11
1527
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 pages were created. Thanks. Jonathan
14
75493
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" enctype="multipart/form-data" name="form1"> <select onchange="this.form.submit();" name="prod"> <option value="">Select product</option> <option value="12">abc</option>
1
2259
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 $VM_LANG->_('PHPSHOP_CART_ADD_TO') ?> ). If There is button when user click on it the pop-up messege will come up and user stays at the same webpage. ut with radio button ofter Click user is redirected to the Virtuemart shopping cart but I wish that Ajax...
0
8472
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8596
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
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
5690
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
4221
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1801
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.