With the support of filefilereader, how to implement asynchronous file upload in php with Ajax technology makes asynchronous file Upload easier. (Previously, the form will be submitted to iframe for implementation) Ajax
1: Get the file object
2: read binary data
3: simulate http requests and send data (this is usually troublesome)
Use the sendasbinary method of the xmlhttprequest object to send data under forefox;
4: Perfect Implementation
Problems encountered
Currently, only firefox can correctly upload files. (Chrome can also be uploaded using google. gears)
The file data read from firefox and chrome is different (I don't know if it is the reason for the debugging tool)
Chrome and other advanced browsers do not have the sendasbinary method and can only use the send method to send data. it may be because the above causes the upload to fail correctly. (Normal text files can be uploaded correctly after testing)
The code is as follows:
Html5 file and filereader
(Drag the image here) get the file base64 encoding using filereader