Forums | Support | Document | Company
File Upload

PHP File Uploader

Advanced PHP Upload Solution
Buy Now

Deployment PHP File Uploader

PHP File Uploader is 100% HTML and JavaScript code on the client, and PHP code on the server, and can be setup on your web server in just 5 minutes, simply by following this setup guide.

1. Deploying Uploader Client files.

The "phpuploader" folder and all file it contains (located in the archive) should be deployed to http://{your site}/{your application}/phpuploader/ on your web site.

2. Adding Uploader into PHP page.

  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" action="upload.php">   
  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: Render Uploader   
  12.                 $uploader->Render();   
  13.             ?>   
  14.         </form>   
  15. </body>   
  16. </html>  

This form sends data to the file "upload.php", which is what we will be creating next to actually upload the file.

3. Saving the Uploaded File.

The "upload.php" file contains the code for uploading a file. When the uploader.php file is executed, the uploaded file exists in a temporary storage area on the server. If the file is not moved to a different location it will be removed! To store the uploaded file we need to copy it to a different location using CopyTo or MoveTo method.

  1. //Step 1: Register Uploader component to your page   
  2. <?php require_once "phpuploader/include_phpuploader.php" ?>   
  3. <html>   
  4. <body>   
  5. <?php   
  6. //Gets the GUID of the file based on uploader name   
  7. $fileguid=@$_POST["myuploader"];   
  8. if($fileguid)   
  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. </body>   
  31. </html>  
   
This control is also available for ASP.NET!

Ajax Uploader for .NET
Server Requirements Requirements

Compatible with PHP 5.0+.
Copyright 2003-2010 PHP File Uploader. All rights reserved. | Ajax Uploader for ASP.NET | ASP File Uploader