Uploading Multiple Files

php Uploader

PHP File Uploader

Uploading Multiple Files

PHP File Uploader allows you to select multiple files and upload multiple files at once.

1. Adding Uploader into PHP page and setting MultipleFilesUpload property to true.
  1. //Step 1: Register Uploader component to your page   
  2. <?php require_once "phpuploader/include_phpuploader.php" ?>   
  3. <html>   
  4. <body>   
  5.         <form id="form1" method="POST">   
  6.             <?php   
  7.                 //Step 2: Create Uploader object.   
  8.                 $uploader=new PhpUploader();   
  9.                 //Step 3: Set a unique name to Uploader   
  10.                 $uploader->Name="myuploader";    
  11.                 //Step 4: Enable Multiple Files Upload.   
  12.                 $uploader->MultipleFilesUpload=true;   
  13.                 //Step 5: Render Uploader   
  14.                 $uploader->Render();   
  15.             ?>   
  16.         </form>   
  17. </body>   
  18. </html>  
2. Retrieving all uploaded files.
  1. <?php   
  2. //Gets the file GUID list based on uploader name      
  3. $fileguidlist[email protected]$_POST["myuploader"];   
  4. if($fileguidlist)   
  5. {   
  6.     $guidlist=split("/",$fileguidlist);    
  7.     foreach($guidlist as $fileguid)   
  8.     {   
  9.        
  10.         //get the uploaded file based on GUID      
  11.         $mvcfile=$uploader->GetUploadedFile($fileguid);      
  12.         if($mvcfile)      
  13.         {      
  14.              //Gets the name of the file.      
  15.              echo($mvcfile->FileName);      
  16.              //Gets the temp file path.      
  17.              echo($mvcfile->FilePath);      
  18.              //Gets the size of the file.      
  19.              echo($mvcfile->FileSize);       
  20.               
  21.              //Copys the uploaded file to a new location.      
  22.              $mvcfile->CopyTo("/uploads");      
  23.              //Moves the uploaded file to a new location.      
  24.              $mvcfile->MoveTo("/uploads");      
  25.              //Deletes this instance.      
  26.              $mvcfile->Delete();      
  27.         }   
  28.     }   
  29. }   
  30. ?>  
This control is also available for ASP.NET!

Ajax Uploader for .NET