05 June 2011

How to upload multiple files at once?

In previous post i have discussed how you can add multiple file tags on a web page at once ,
You can check it by clicking here
Today i will explain how can you upload multiple files at once using PHP, you can use below mentioned script written in php to upload multiple files at once


<?php
if($_POST['submit']=='Submit')
{
$files=$_FILES["file"]["name"];
for($i=0;$i<count($files);$i++)
{
if (file_exists("upload/" . $_FILES["file"]["name"][$i]))
{
echo "File already exists";
break;
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"][$i],"upload/" . $_FILES["file"]["name"][$i]);
}
}
}
?>


You can check description of tags used in this script by clicking here


If still have any query ,feel free to put it here