Simple File Upload - PHP file upload script

The simplest way to allow people to include large file uploads inside your web forms.
Forget your web server limits.
Keep your existing scripts.

Free for personal use
Upload files up to 2 GB
No registration required
No plugin needed (no Flash, no Java)
Integrates seamlessly in existing forms
Totally transparent for users
Secured by SSL

Home Features Demo Premium membership About Contact

Specifications

Simple-File-Upload is compatible with all web browsers including Internet Explorer, Mozilla Firefox, Chrome, Safari, etc.

The total upload size is limited to 2 GB due to web browsers’ internal limitations.

Our system uploads files via the proven web standard HTML form technology, a method which has been used for decades. There is no need for any plugin like Flash or Java.

You can set up your HTML form as you normally do, with no restrictions. Feel free to include text input fields, dropdown lists, radio buttons or checkboxes. Including, of course, as many file upload fields as you require. The field names are strictly preserved.

Basic setup

You only need to change the target URL of your <FORM> tag, to have the data go through our server.
Don't forget to set up the correct 'METHOD' and 'ENCTYPE' parameters, or the upload will fail.

 <form 
  action="http://www.simple-file-upload.com/upload?url=http://your-website.com/your-contact-script.php"
  method="post" enctype="multipart/form-data">
    ... include input fields ...
    Select your image file : <input name=user_picture type=file>
    ...
 </form>

On the server-side you can collect the text fields values as usual.
The file upload fields will be replaced by a text value in the following format : FILENAME=URL-TO-RETRIEVE-FILE-DATA
Example : POST[user_picture] : My simple pic.jpg=http://www.simple-file-upload.com/files/ad9e6157b373339cbc4e8f5b4052ac36

Here is a sample PHP script for reading values and sending an email :
  <?php
    $html 
"";
    foreach(
$_POST as $field=>$value) {
      if(
$field=="my_file_field") {
        
$value str_replace('<'''$value);  // protect ourself from injection
        
$array explode("="$value);
        
$html .= "Download link : <a href={$array[1]}>{$array[0]}</a><br>";
      } else {
        
$html .= "<b>".htmlentities(ucfirst(str_replace('_',' ',$field)))."</b> : ".htmlentities(nl2br($value))."<br>";
      }
    }
    
mail("webmaster@my-website.com""New upload"$html);
    echo 
"Thank you !";
  
?>

Here is a sample PHP script for reading values and retrieving the files onto the local server :
  <?php
    
foreach($_POST as $field=>$value) {
      if(
$field=="my_file_1" || $field=="my_file_2") {
        
$value str_replace('<'''$value);  // protect ourself from injection
        
$array explode("="$value);
        
$filename $array[0];  // don't forget to check file extension and real file type !
        
$url $array[1];

        
// protect ourself from dangerous URLs (local files or non HTTP url)
        
if(substr($url034) != 'http://www.simple-file-upload.com/') die("Invalid URL");  

        if(!
copy($url"pictures/SOMEUSERID_".$field.".jpg"))  // let PHP retrieve the data from remote server
          
echo "Error during copy of ".htmlentities($url)." to local directory !<br>";

      } else {
        
// do something else with text fields ...
      
}
    }
    echo 
"Upload complete.";
  
?>

How to get an asynchronous callback with form data

When using the 'url' parameter, once the upload has been completed, it's the user who triggers the script on your website. The user is transparently redirected to your own script, with the text field data and the download links for the uploaded files. You can then retrieve the files from your script, avoiding web-server file size limitations.
If the uploaded files are large, you can choose to get a callback from our server to your script, while the user is instantly redirected to a confirmation page. By using this method, the user won't have to wait for your script to finish retrieving the files from our server.
This is done by setting both the 'url' and 'redirect' parameters in the target URL of your <FORM> :

 <form action="http://www.simple-file-upload.com/upload?url=http://my-website.com/send.php&redirect=http://my-website.c
 om/thank-you.htm" ...

How to receive the form data by email

If you don't have an existing script to collect the data, you can choose to simply receive the information by email instead of having it transmitted to an external script.



This is done by setting the 'email' parameter in the target URL of your <FORM> :

 <form action="http://www.simple-file-upload.com/upload?email=webmaster@your-website.com" ...

By default, the user will be redirected to your original web page (based on HTTP REFERER header) once the upload is completed.
But you can choose to redirect the user to a custom URL instead, by providing an additional 'redirect' parameter :

 <form action="http://www.simple-file-upload.com/upload?email=webmaster@your-website.com&redirect=http://your-website.com/th
 ank-you.htm" ...

How to display a progress bar when uploading

By default, Simple-File-Upload is integrated seamlessly, with no significant or visible modification to your website that your users will be aware of.
If you want, however, you can display a simple progress bar (thanks to Ajax) within your form which will look like this:



 <form id="my_upload_form" action="http://www.simple-file-upload.com/upload?url=...">
   ... 
 </form>
 <script src='http://www.simple-file-upload.com/progressbar?form=my_upload_form'></script>

This progress bar is compatible with Internet Explorer 7+, Mozilla Firefox, Chrome and Safari.
You can tweak the design of the progress bar by wrapping it inside a DIV and applying some custom CSS styles. More pre-defined settings will be available soon.

How to use SSL encryption

The website located on www.simple-file-upload.com is available for both encrypted and unencrypted connections.
You can use URLs starting with http://www.simple-file-upload.com (regular connection) or https://www.simple-file-upload.com (encrypted by SSL).
If you want to ensure the connection is secure while your user is uploading their files, you simply have to specify a target URL starting with 'https' in your form.
© Helix Multimedia 2012 - All rights reserved