By using HTML5 approach, multiple files can be uploaded through a single click. Please look at the script below.
<input type="file" name="multifile[]" multiple="multiple">
multiple="multiple" is an HTML5 construct, to select multiple files at once. Now come to PHP.
$files=array();
$fdata=$_FILES['multifile'];
if(is_array($fdata['name'])){
for($i=0;$i<count($fdata['name']);++$i){
$files[]=array(
'name' => $fdata['name'][$i],
'tmp_name' => $fdata['tmp_name'][$i],
); } }
else $files[]=$fdata;
foreach ($files as $file) {
$target_path = $target_path . basename($file['name']);
move_uploaded_file($file['tmp_name'], $target_path)
}