Today we will see how can we write a code to upload mutilpe files, this is pretty simple. You can do it using one file or one html file and php file.

Today will see how we can do it with a single ( please see I am not adding bells and whistles)
// Absolute path of location where file is to be uploaded and don’t forget to have CHMOD 777 for it
$fileDir = “absolute path to location”;
$intuploadcount = 0;
for ($intCount=0;$intCount<$numoffile;$intCount++)
{
//Check if the all the input box have data or not
if (trim($_FILES['file']['name'][$intCount])!="")
{
$newfile = $file_dir.$_FILES['file']['name'][$intCount];
move_uploaded_file($_FILES['file']['tmp_name'][$intCount], $newfile);
$intuploadcount++;
}
}

if (isset($intuploadcount)&& $intuploadcount>0)

print “$intuploadcount files uploaded
“;

if (isset($intuploadcount)&& $intuploadcount>0)

print “$intuploadcount files uploaded
“;

// echo “

“;
//for($i=0;$i<$filecount;$i++) {
// echo "
“;
//}
// echo “
“;
//echo “

“;
//?>
?>
Doing with html and php files is simple, you just need to create form in html and instead of using ‘for’ loop to generate box, you need to make different box and then create another file ( name it ) and in action of form give the name of file..

That;s it, it should work now.

Share