The traditional way of uploading files
<formAction=""Method= "POST"enctype= "Multipart/form-data"><inputtype= "File"name= "File"/><inputtype= "Submit"/></form>
After the upload is performed, the page jumps to the address specified by the action.
The general user needs to upload a file with no page refresh, at which point the IFRAME can be used to redirect the returned content after the form form is submitted to the IFRAME.
The modified code is
<formAction=""Method= "POST"Target= "Target"enctype= "Multipart/form-data"><inputtype= "File"name= "File"/><inputtype= "Submit"/></form><iframename= "Target"ID= "Target"frameborder= "0"width= "0"Height= "0"></iframe><Script> variframe=document.getElementById ("Target"); varUploadcallback= function() {console.log (Iframe.contentDocument.body.innerHTML); }; Iframe.onload=Uploadcallback;</Script>
The onload event of the IFRAME is used to detect whether the transmission is complete and to obtain the return value of the service side after the transfer.
The example is very simple and there is a case of browser incompatibility, but the basic idea of uploading plugins is so.
In addition, there are SWF ways to achieve the actual upload speed and progress and other information.
JS No refresh Upload file