Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > ajax multipart problem

Reply
Thread Tools

ajax multipart problem

 
 
charles
Guest
Posts: n/a
 
      05-18-2007
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.

 
Reply With Quote
 
 
 
 
Skye Shaw!@#$
Guest
Posts: n/a
 
      05-20-2007
On May 18, 9:46 am, charles <char...@boisvert.me.uk> wrote:
> Hello,
>
> I'm trying to use AJAX to send multipart data (not from a client


> 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.


Works for me. Can you post the text of the error as listed the
JavaScript console?

 
Reply With Quote
 
 
 
 
charles
Guest
Posts: n/a
 
      05-20-2007
On 20 mai, 19:18, "Skye Shaw!@#$" <skye.s...@gmail.com> wrote:
> On May 18, 9:46 am, charles <char...@boisvert.me.uk> wrote:
>
>
>
> > Hello,

>
> > I'm trying to useAJAXto sendmultipartdata (not from a client
> > 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.

>
> Works for me. Can you post the text of the error as listed the
> JavaScript console?


Firefox:

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIXMLHttpRequest.send]"
nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS
frame :: file:///C:/charles/compile.html :: <TOP_LEVEL> :: line 39"
data: no]


 
Reply With Quote
 
Skye Shaw!@#$
Guest
Posts: n/a
 
      05-21-2007
On May 20, 2:44 pm, charles <char...@boisvert.me.uk> wrote:
> On 20 mai, 19:18, "SkyeShaw!@#$" <skye.s...@gmail.com> wrote:
>
>
>
> > On May 18, 9:46 am, charles <char...@boisvert.me.uk> wrote:

>
> > > Hello,

>
> > > I'm trying to useAJAXto sendmultipartdata (not from a client
> > > 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.

>
> > Works for me. Can you post the text of the error as listed the
> > JavaScript console?

>
> Firefox:
>
> Error: uncaught exception: [Exception... "Component returned failure
> code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIXMLHttpRequest.send]"
> nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS
> frame :: file:///C:/charles/compile.html :: <TOP_LEVEL> :: line 39"
> data: no]



You need to test this via a web server, as you are making a XML /Http/
Request.


 
Reply With Quote
 
charles
Guest
Posts: n/a
 
      05-22-2007

> > > > 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);

>


charles> When I try to send the request, I get an error "File not
charles> found" in Firefox, "Resource not found" in IE. But I'm not
charles> reading a file?? I'm puzzled.

shaw> Works for me. Can you post the text of the error as listed the
shaw> JavaScript console?

charles> Firefox:
charles> Error: uncaught exception: [Exception... "Component
charles> returned failure code: 0x80520012
charles> (NS_ERROR_FILE_NOT_FOUND) [nsIXMLHttpRequest.send]"
charles> nsresult: "0x80520012
charles> (NS_ERROR_FILE_NOT_FOUND)" location: "JS
charles> frame :: file:///C:/charles/compile.html :: <TOP_LEVEL> ::
charles> line 39" data: no]

shaw> You need to test this via a web server, as you are making a
shaw> XML /Http/ Request.

Oops... I thought it was enough to connect to a server. Thanks.

Charles


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MIME Structure Multipart/Mixed with attachment and Multipart/Alternative blaine@worldweb.com Perl Misc 1 04-04-2007 08:23 PM
Submit Formwith AJAX Using ENCTYPE="multipart/form-data" vunet.us@gmail.com Javascript 4 03-20-2007 02:46 PM
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM
ajax + prototype.js + multipart/form-data NextOne Javascript 3 09-30-2005 05:13 PM
multipart/form-data problem Alex Sibilev ASP .Net 4 10-26-2004 02:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57