This article mainly introduces their own write a pseudo Ajax image upload implementation code, need friends can refer to the following
Code as follows: <?php if ($_files) { ?> <script> Window.parent.ajaxUploadPicture.uploadCallback (' HTTP://IMG0.BDSTATIC.COM/IMG/IMAGE/5099213B07ECA8065380CE 7f75e95dda144ad348269.jpg '); </script> <?php die; } ?> <! DOCTYPE html> <html> <head> <script> ajaxuploadpicture = {$ O1: '}; ajaxuploadpicture.ajaxuploadfile = function ($o) { this. $o 1 = $o; var $iframe = do Cument.createelement (' iframe '); $iframe. style.display = ' None '; $iframe. Name = ' iframe '; $iframe. Id = ' iframe '; document.body.appendChild ($iframe); var $form = document.createelement ("form"); nbsp $form. Method = "Post"; $form. enctype = "Multipart/form-data"; $form. Action = ""; $form. Target = ' iframe '; $newO = $o. CloneNode (); $form. appendchild ($newO); $form. Submit (); } AJaxuploadpicture.uploadcallback = function ($url) { $pic = document.createelement (' img '); $pic. Width = "; " $pic. Height = "; " $pic. src = $url; if (document.getElementById (' picshow ') = null) {&N Bsp $div = document.createelement ("div"); $div. id = ' Picshow '; this. $o 1.parentnode.insertbefore ($div, this.$ o1.nextsibling); }else{ $div = document.getElementById (' picshow '); } $div. InnerHTML = '; $div. appendchild ($pic); }; </script> </head> <body> <input Type= "File" name= "file" onchange = "ajaxuploadpicture.ajaxuploadfile (this);" > </body> </html> Object oriented thinking, form commits to a hidden IFrame, executes the callback JS function. Implement a picture echo. The function of the backstage PHP is not perfect.