I actually want to send a picture to my server using jQuery without using html form. But I would like to retrieve the same data as I received with an html form with the encode type:
multipart/form-data
I used HTML5 FileReader : http://www.html5rocks.com/en/tutorials/file/dndfiles/
but when I use FileReader.readAsText(Blob|File, opt_encoding)
function. The data I retrieved are not encoded as the same as it's encoded with the html form.
What encoding is used for "multipart/form-data" and is it possible to encode data using jquery or javascript before send them to my server?
//edit
from w3schools : http://www.w3schools.com/html5/att_form_enctype.asp
multipart/form-data ==> No characters are encoded. This value is required when you are using forms that have a file upload control
the problem that I have is that when I retrieve the data from FileReader it's not the same data that from HTML form data.
for the same picture: with html form :
\xff\xd8\xff\xe1\x00\x18Exif\x00\x00II*\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xec\x00\x11Ducky\x00\x01\x00\x04\x00\x00\x00U\x00\x00\xff\xe1\x03)http://ns.adobe.com/xap/1.0/\x00<?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>...
with FileReader.readAsText():
\xc3\xbf\xc3\x98\xc3\xbf\xc3\xa1\\u0000\\u0018Exif\\u0000\\u0000II*\\u0000\\b\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\xc3\xbf\xc3\xac\\u0000\\u0011Ducky\\u0000\\u0001\\u0000\\u0004\\u0000\\u0000\\u0000U\\u0000\\u0000\xc3\xbf\xc3\xa1\\u0003)http://ns.adobe.com/xap/1.0/\\u0000<?xpacket begin=\\"\xc3\xaf\xc2\xbb\xc2\xbf\\" id=\\"W5M0MpCehiHzreSzNTczkc9d\\"?>
How to retrieve the same data?