Home >Backend Development >PHP Tutorial >Code example of how to implement asynchronous file upload through Ajax in PHP_PHP Tutorial
1: Get the file object
2: Read binary data
3: Simulate http request and send the data (this is usually more troublesome)
Use the sendasbinary method of the xmlhttprequest object under forefox to send data;
4: Perfect implementation
Problems encountered
Currently only firefox can upload files correctly. (Chrome can also use google.gears to upload)
The file data read from Firefox and Chrome seems to be different (I don’t know if it is due to the debugging tool)
Chrome and other advanced browsers do not have sendasbinary method Data can only be sent using the send method. It may be due to the above reasons that the data cannot be uploaded correctly. (After testing, ordinary text files can be uploaded correctly)