Upload multiple images with PHP

Submitted by n8coder on Sun, 05/17/2009 - 15:56


/**
* Smart Image Uploader by @cafewebmaster.com
* Free for private use
* Please support us with donations or backlink
*/

$upload_image_limit = 5; // How many images you want to upload at once?
$upload_dir = ""; // default script location, use relative or absolute path

################################# UPLOAD IMAGES

foreach($_FILES as $k => $v){

$img_type = "";

### $htmo .= "$k => $v


"; ### print_r($_FILES);

if( !$_FILES[$k]['error'] && preg_match("#^image/#i", $_FILES[$k]['type']) && $_FILES[$k]['size'] < 1000000){

$img_type = ($_FILES[$k]['type'] == "image/jpeg") ? ".jpg" : $img_type ;
$img_type = ($_FILES[$k]['type'] == "image/gif") ? ".gif" : $img_type ;
$img_type = ($_FILES[$k]['type'] == "image/png") ? ".png" : $img_type ;

$img_rname = $_FILES[$k]['name'];
$img_path = $upload_dir.$img_rname;

copy( $_FILES[$k]['tmp_name'], $img_path );
$feedback .= "Image and thumbnail created $img_rname
";

}
}

############################### HTML FORM
while($i++ < $upload_image_limit){
$form_img .= '
';
}

$htmo .= '

'.$feedback.'

'.$form_img.'

Powered by Cafe Webmaster

';

echo $htmo;

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.