If the user is prompted to upload the success, then if the user upload a larger file, then the half are not reflected, then the user is likely to refresh or close the never ...
So it will have a certain impact on our servers, so we can improve the user experience in this area, such as to do the same as we often see the progress bar
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title> <Scriptsrc= "Jq183.js"></Script> <Script> functionAjaxup () {varifname= ' up'+Math.random (); $("<iframe name= '"+ifname+"' height= ' 0 ' width= ' 0 ' frameborder= ' 0 ' ></iframe>"). AppendTo ($ ('Body')); $('Form:first'). attr ('Target', ifname); /*add an identity in an upload*/ $('#jindu'). HTML (''); //return false; } </Script></Head><Body> <PID= "Mess"></P> <PID= "Jindu"></P> <formAction= "9.php"Method= "POST"enctype= "Multipart/form-data"onsubmit= "return Ajaxup ();"> <inputtype= "File"name= "Pic"> <BR> <BR> <inputtype= "Submit"value= "GO"> </form> <iframesrc=""frameborder= "0"></iframe></Body></HTML>
<?PHP//simulate a relatively large file being uploaded Sleep(3); if(Empty($_files)){ Exit(' No file '); } $errs=$_files[' Pic '] [' error '] = = 0? ' Success ': ' Error '; Echo"<script> parent.document.getElementById (' Mess '). InnerHTML = '$errs' </script> '; //shut him down after the upload was successful . Echo"<script> parent.document.getElementById (' Jindu '). style.display = ' None ' </script>";
The effect is as follows:
Ajax-----11iframe Analog Ajax File Upload effect principle 3