This article mainly introduces the relevant information about three asynchronous file upload methods in JavaScript. For more information, see the asynchronous file upload method. This is a good user experience and a skill that each front-end must possess. Here I propose three methods for asynchronous file upload.
Use third-party controls, such as Flash, ActiveX, and other browser plug-ins.
Use a hidden iframe to simulate asynchronous upload.
Use XMLHttpRequest2 for asynchronous upload.
The first method is to use the browser plug-in for upload, which requires a certain level of underlying coding skills. I will not talk about it here, so as to avoid mistakes. If you propose this, you can use Baidu.
Second, simulate asynchronous upload using a hidden iframe. Why is simulation described here? Because we put the returned results in a hidden iframe, we didn't redirect the current page, just like an asynchronous operation.
First paste the Code:
Upload a file using a hidden iframe