C
charles
Hello,
I'm trying to use AJAX to send multipart data (not from a client
file), and I'm using a requestbody with the files separated by a
boundary, like that:
var boundStr = 'capitano';
var boundary = '--' + boundStr;
var requestbody = [
boundary,
'Content-Disposition: file; name="htmlfile";
filename="hello.html"',
'Content-Type: text/html',
'',
'<html>some file</html>,
boundary,
'Content-Disposition: form-data; name="jdk_version"',
'',
jdkVersion,
boundary
].join('\n');
And then I set the headers and send, like that:
httpRequest.onreadystatechange = requestdone;
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader('Content-type', 'multipart/form-
data; boundary="' + boundStr + '"');
httpRequest.send(requestbody);
Now when I try to send the request, I get an error "File not found" in
Firefox, "Resource not found" in IE. But I'm not reading a file?? I'm
puzzled.
Any ideas welcome.
I'm trying to use AJAX to send multipart data (not from a client
file), and I'm using a requestbody with the files separated by a
boundary, like that:
var boundStr = 'capitano';
var boundary = '--' + boundStr;
var requestbody = [
boundary,
'Content-Disposition: file; name="htmlfile";
filename="hello.html"',
'Content-Type: text/html',
'',
'<html>some file</html>,
boundary,
'Content-Disposition: form-data; name="jdk_version"',
'',
jdkVersion,
boundary
].join('\n');
And then I set the headers and send, like that:
httpRequest.onreadystatechange = requestdone;
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader('Content-type', 'multipart/form-
data; boundary="' + boundStr + '"');
httpRequest.send(requestbody);
Now when I try to send the request, I get an error "File not found" in
Firefox, "Resource not found" in IE. But I'm not reading a file?? I'm
puzzled.
Any ideas welcome.