You can use blueimp jQuery File Upload for the client side to have multiple file downloads. It has many options, customizable.
For the PHP side, you might be interested in some ideas on what to do (just some snippet for my upload form for images, so some variables are not defined here like $ log or $ confImages, but you can get this idea)
if (empty($uploaded_image))
return false;
if ($uploaded_image['error']) {
$log->LogError($uploaded_image['error'] . ": Error uploading file.");
return false;
}
list($dirname, $basename, $extension, $filename) = array_values(pathinfo($uploaded_image['name']));
$filename = iconv("utf-8","ascii//TRANSLIT",$filename);
$allowedExt = array("jpg","jpeg","gif","png");
$extension = strtolower($extension);
if (empty($extension) || !in_array($extension, $allowedExt)) {
$log->LogError("invalid_extension: Not allowed to upload file ".(empty($extension) ? "without extension" : "with extension $extension").". Allowed Extensions: ". implode(",",$allowedExt));
return false;
}
$postfix = substr( md5(uniqid(rand(),1)), 3, 5 );
$newFile = $_SERVER['DOCUMENT_ROOT'].$upload_folder."/".$filename.'_'.$postfix.'.'.$extension;
if (file_exists($newFile)) {
$log->LogError("file_exists: File couldn't be uploaded, because such filename exist ".basename($newFile)." jau eksistē");
}
if (move_uploaded_file($uploaded_image['tmp_name'],$newFile)) {
$convertedimage = PhpThumbFactory::create($newFile, array("jpegQuality" => 80));
if (isset($confImages["max_width"]) || isset($confImages["max_height"]))
$convertedimage->resize($confImages["max_width"], $confImages["max_height"]);
$convertedimage->save( $newFile );
...
return $image;
} else {
$log->LogError("Couldn't copy file from temp folder " . $uploaded_image['tmp_name'] . " to location " . $newFile);
}
return false;
source
share