0

I'm using noswfupload (ajax uploader) with my web application, and it work fine with Firefox and IE, but it's not working with Google Chrome. I found an error which show that "PHP Warning: Missing boundary in multipart/form-data POST data in Unknown on line 0"

could anyone tell me how to solve this problem?

Alwayz Change
  • 225
  • 1
  • 4
  • 13
  • Looks like the library has a bug where it's not formatting the request correctly. Is there a bug tracker with that library? – beatgammit Sep 18 '11 at 15:58
  • nop !! i found an error in error log file. – Alwayz Change Sep 18 '11 at 16:07
  • If it doesn't work in Google Chrome, then it probably doesn't work for Safari as well. Is there a reason why you're using this framework instead of using the [FormData](http://hacks.mozilla.org/2010/05/formdata-interface-coming-to-firefox/) object? – beatgammit Sep 18 '11 at 16:14
  • I can customize it and integrate with my web application easily with its event and object, also no require any other framework such as jQuery or mootools. I'm trying to fix it :) – Alwayz Change Sep 19 '11 at 14:32

1 Answers1

0

Not sure about your specific uploader, but:

This error is a problem with the way that your xhr request headers are set, and also your request data. Valid syntax ( from my chrome debug console ) looks like this:

request header:

Content-Type:multipart/form-data; boundary=----WebKitFormBoundarykEVXyg09HZBMzplL

request data:

------WebKitFormBoundarykEVXyg09HZBMzplL
Content-Disposition: form-data; name="foo_bar"

data:image/jpeg;base64,/9j/4AAQSkZJ
     [....]
pAkhCD/9k=
------WebKitFormBoundarykEVXyg09HZBMzplL--

You can see the http rfc here: http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html , it mentions the boundary syntax in the header....

You can manually change the header as in this answer: How to send multipart/form-data form content by ajax (no jquery)? , or you can try to solve it at a higher level.

The formData object can mimic those parameters too, (although it's not implemented in all browsers) ... https://developer.mozilla.org/en/DOM/XMLHttpRequest/FormData/Using_FormData_Objects

I had a problem with a jquery ajax call to a php file (with the same error) and solved it by ditching jquery and using formData and the raw httpxhrrequest.

Community
  • 1
  • 1
awongh
  • 1,308
  • 12
  • 21