Hide the new iframe file without refreshing, and the iframe refreshes the uploaded file. Hide the iframe without refreshing the newly uploaded File. iframe refreshes the uploaded file. first, ajax cannot upload the file, which leads to some time, if you can't sleep tonight, follow the instructions to make a new Upload without refreshing the file, hide the iframe, and refresh the uploaded file.
First, ajax was unable to upload files, which misled me for a while. if I couldn't sleep tonight, I followed the instructions to upload a new file without refreshing.
In fact, the principle is very simple
<Pre class = "code"> class upload <br/>{< br/> public $ _ file; <br/> public function _ construct ($ name = null) <br/>{< br/> if (is_null ($ name) |! Isset ($ _ FILES [$ name]) <br/> $ name = key ($ _ FILES); <br/> if (! Isset ($ _ FILES [$ name]) <br/> throw new Exception ("no file upload "); <br/> $ this-> _ file = $ _ FILES [$ name]; <br/> if (! Is_uploaded_file ($ this-> _ file ['tmp _ name']) <br/> throw new Exception ("Exception "); <br/> if ($ this-> _ file ['error']! = 0) <br/> throw new Exception ("error code :". $ this-> _ file ['error']); <br/>}< br/> public function moveTo ($ new_dir) <br/>{< br/> $ real_dir = $ this-> checkDir ($ new_dir ); <br/> return move_uploaded_file ($ this-> _ file ['tmp _ name'], $ real_dir. '/'. $ this-> _ file ['name']); <br/>}< br/> private function checkDir ($ dir) <br/>{< br/> $ real_dir = realpath ($ dir); <br/> if ($ real_dir = false) <br/> throw new limit T Ion ("The specified directory {$ dir} does not exist"); <br/> if (! Is_writable ($ real_dir) <br/> throw new Exception ("the given directory {$ dir} cannot be written"); <br/> return $ real_dir; <br/>}</pre> <pre class = "code" >}</pre> <p> Call example: </p> <pre class = "code"> $ inputName = 'uploadfile'; <br/> // <input type = & ldquo; name value in file "name =" uploadfile "/>. this parameter is optional. <br/> $ upload = new upload ($ inputName ); <br/> $ new_dir = "/www"; // path to which the file is moved <br/> $ upload-> moveTo ($ new_dir ); </pre> <p> </p> <p align = "left"> <p style = "display: none;"> http://www.bkjia.com/PHPjc/1105144.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1105144.htmlTechArticle Hide the iframe file without refreshing the new Upload. iframe refreshes the uploaded file. first, ajax cannot upload the file. This misled me for a while. if I can't sleep tonight, I will follow the instructions to upload the file without refreshing... </p> <p class = "art_confoot">