Is this a normal multipart post request? If not, perhaps you should use request.body.read() and log what is in there.
On Thursday, 27 March 2014 07:48:39 UTC-5, ayresrichard wrote: > > > I am developing a web browser application where the user must upload a > image file to a web2py server. > > I am using the traditional way for file input, which, in the iPad, gives > the option to either upload an existing picture or take a new one from the > camera. > > var url = "http://please-help-me.com"; > var file = document.getElementById("file").files[0]; > > > var fd2 = new FormData(); > fd2.append("upload", file); > fd2.append("id", 123); > > > var reader = new XMLHttpRequest(); > reader.open('post',url, true); > reader.onreadystatechange = function() { > console.log("Status:" + reader.status); > } > reader.send(fd2); > > > This works fine in the desktop browsers, Android browser, but not in the > iPad, where it occasionally gives a 400 Bad Request Error. It doesn't > return the error every time. Just sporadically. > > Web2py returns this error message: > > ERROR:Rocket.Errors.Thread-20:Traceback (most recent call last): > File "/home/mdipierro/make_web2py/web2py/gluon/rocket.py", line 1337, inrun > File "/home/mdipierro/make_web2py/web2py/gluon/rocket.py", line 1838, > inrun_a > pp > File "/home/mdipierro/make_web2py/web2py/gluon/main.py", line 651, > inapp_with > _logging > File "/home/mdipierro/make_web2py/web2py/gluon/main.py", line 532, > inwsgibase > File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 252, inbody > HTTP: 400 BAD REQUEST > > > Searching in the code, it appears the content of the post message is not > valid and the web2py body function has trouble reading it. The error rises > when I try to read the request.post_vars data > > I've tested the code without sending the image (and only sending other > data) and it seems to be working every time. Is there a specific parameter > I should add to the request? Why does it work sometimes, but not all the > time? > > Thanks > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

