Hi there
I am working on multiple upload file and how to get the height and width of each images to know if their dimensions accet the permitted height and width (500 x 500):
my [php]echo output 3times the width of file[/php]…instead of 1…it is like a loop.
I have tried but it is not working the way i want…can somebody help?
HERE is my code
[php]
[/php] PHP: [php]define('MAX_FILE_SIZE', 751200); if(array_key_exists('etape2', $_POST)){ $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg','image/png'); /*$img1 = $_FILES['image']['tmp_name'][0]; $img2 = $_FILES['image']['tmp_name'][1]; $img3 = $_FILES['image']['tmp_name'][2];*/
foreach ($FILES[‘image’][‘name’] as $number => $file) {
// replace any spaces in the filename with underscores
$file = str_replace(’ ', '’, $file);
// begin by assuming the file is unacceptable
$sizeOK = false;
$typeOK = false;
// check that file is within the permitted size
if ($_FILES[‘image’][‘size’][$number] > 0 || $_FILES[‘image’][‘size’][$number] <= MAX_FILE_SIZE) {
$sizeOK = true;
}
// check that file is of a permitted MIME type
foreach ($permitted as $type) {
if ($type == $_FILES[‘image’][‘type’][$number]) {
$typeOK = true;
break;
}
}
list($width, $height) = getimagesize($_FILES[‘image’][‘tmp_name’][0]);
echo $width;
}//end main foreach
}//end main post
[/php]