PHP jquery multiple file Upload simple example

Source: Internet
Author: User
Tags file upload

This article mainly introduces the PHP jquery multiple file Upload simple examples, the need for friends can refer to

  Code as follows: <div id= "Mulitplefileuploader" >Upload</div>     <div id= "status" ></div >   <script>     $ (document) Ready (function ()   {    var settings = {  &NBSP ;   URL: "upload.php",       method: "POST",       allowedtypes: "Jpg,png,gif,doc,pdf,zip ",       fileName:" MyFile ",       Multiple:true,       onsuccess:function (f ILES,DATA,XHR)       {          $ ("#status"). HTML ("<font color= ' green ' >UPL Oad is success</font> ");        },       onerror:function (files,status,errmsg)       {  & nbsp              $ ("#status"). HTML ("<font color= ' Red ' >upload is Failed</font > ");      }  }   $ ("#mulitplefileuploader"). UploadFile (settings);    });   </script>         upload.php   code as follows: <?php  //if directory doesnot create it .   $output _dir = ". /upload ";     if (Isset ($_files["myfile"))   {      $ret = array ();         $erro R =$_files["MyFile" ["Error"];      {       !is_array     if ($_files["myfile"] [' name '])//single file &nb Sp         {              $fileName = $_files["MyFile"] ["name"]; &nbs P             Move_uploaded_file ($_files["myfile"] ["Tmp_name"], $output _dir. $_files[" MyFile "] [" name "]);                //echo "<br> error:" $_files["myfile" ["Error"];                       $ret [$fileName]= $output _dir. $fileName;           {          Else &NBsp         {                  $fileCount = count ($_files["M Yfile "[' name ']];                 for ($i =0 $i < $fileCount $i + +)         &N Bsp       {                  $fileName = $_files["MyFile" ["Name"] [$i];                     $ret [$fileName]= $output _dir. $fileName;                   Move_uploaded_file ($_files["myfile"] ["tmp_name"] [$i],$ Output_dir. $fileName);                            }       }       echo Json_encode ($ret);    }    ?>    

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.