Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
38
rated 0 times [  39] [ 1]  / answers: 1 / hits: 18623  / 13 Years ago, wed, june 8, 2011, 12:00:00

I want to post some data to another domain with the enctype equal to multipart/form-data, because I want the unmodified data in the server side.
Here is my test code:



<textarea name=txt rows=20 cols=80>
</textarea>
<script>
function x_domain_post(url, data)
{
var dd = document.createElement('div');
var ifrname = client_proxy;
dd.innerHTML = <iframe id=' + ifrname + ' name=' + ifrname + ' width=0 height=0 ></iframe>;
document.getElementsByTagName('body')[0].appendChild(dd);
var ifr = document.getElementById(ifrname);

var f = document.createElement('form');
f.action = url;
f.method = post;
f.enctype = multipart/form-data;
f.target = ifr.name;
f.innerHTML = f.innerHTML + <textarea name='request'>default</textarea>;
document.getElementsByTagName(body)[0].appendChild(f);
document.getElementsByName(request)[0].value=data;
f.submit()
setTimeout(function(){document.getElementsByTagName(body)[0].removeChild(f);}, 1000);
}

</script>
<button onclick=x_domain_post('http://192.168.232.128/add', document.getElementsByName('txt')[0].value)>


The request in chrome is:



...
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary9zCD31eJSHkdb8ul
...
------WebKitFormBoundary9zCD31eJSHkdb8ul
Content-Disposition: form-data; name=request

a

b

o
------WebKitFormBoundary9zCD31eJSHkdb8ul--


But in IE9:



POST /add HTTP/1.1
...
Content-Type: application/x-www-form-urlencoded
...
request=a%0D%0A%0D%0Ab%0D%0A%0D%0Ao


Any of your help will be appreciated!


More From » forms

 Answers
6

Does this help?



http://www.bennadel.com/blog/1273-Setting-Form-EncType-Dynamically-To-Multipart-Form-Data-In-IE-Internet-Explorer-.htm




Apparently in IE, you have to set the
encoding of the form rather than the
enctype. The good news is, you can
set both values without concern and
this will take care of the problem



[#91814] Monday, June 6, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;