Uploading Multiple Files

In this tutorial, I am gonna teach you that how to create a PHP script code to enable the download of multiple images with PHP/Web Browsing.

The tutorial contains two pages.
1. form.html
2. upload.php


form.html


 

 Note: Multiple file Upload is not supported in Internet Explorer.



upload.php




if(isset($_FILES [‘uploaded_files’]))
{

     foreach($_FILES[‘uploaded_files’][‘name’] as $key=>$value)
     {
          if(is_uploaded_file($_FILES[‘uploaded_files’][‘tmp_name’][$key]) && $_FILES[‘uploaded_files’][‘error’][$key] == 0)
          {
         
                $filename = $_FILES[‘uploaded_files’][‘name’][$key];
     
                if(move_uploaded_file($_FILES[‘uploaded_files’][‘tmp_name’][$key], ‘uploads/’. $filename))
                {

                }
                else
                {
                      die (‘There was a problem uploading the pictures.’);
                }
          }
          else
          {
            die (‘There is a problem with the uploading system.’);
          }
     }

}

?>

Change orange colored uploads to the path you want to save your file on…

Hope you’ll enjoy this article.
Please reply with your comments…

4 Comments

  1. I got the error for uploading images. Could you please have a look my code?

    $value)
    {
    if(is_uploaded_file($_FILES[‘uploaded_files’][‘tmp_name’][$key]) && $_FILES[‘uploaded_files’][‘error’][$key] == 0)
    {

    $filename = $_FILES[‘uploaded_files’][‘name’][$key];

    if(move_uploaded_file($_FILES[‘uploaded_files’][‘tmp_name’][$key], ‘uploads/’. $filename))
    {

    }
    else
    {
    die (‘There was a problem uploading the pictures.’);
    }
    }
    else
    {
    die (‘There is a problem with the uploading system.’);
    }
    }

    }

    $Images=$_POST[‘images’];
    $save=mysql_query(“INSERT INTO images) VALUES
    (‘$images’)”);

    header(“location: form.html”);
    exit();
    ?>

Leave a Reply

Your email address will not be published. Required fields are marked *