Hide the iframe file without refreshing, and refresh the uploaded file with iframe _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.