Question

i am getting this error when i attempt to use the image resize script for each of the multiple images

the error:Fatal error: Cannot redeclare class SimpleImage

i am using the resize script by whitehat

my script for handling multiple file uploads

foreach($_FILES['image']['tmp_name'] as $key => $tmp_name )
{   
$file = $_FILES['image']['tmp_name'][$key];//temp file
$image_name = $key.$_FILES['image']['name'][$key];//ini file name

////resize image------
include('resizer.php'); 
$image = new SimpleImage(); 
$image->load($_FILES['image']['tmp_name'][$key]); 
$image->resize(150,150);
$image->save('photos/'.$image_name.''); 
////----end resizer---- 

move_uploaded_file($file,"photos/".$image_name);
}

what should i do to fix my problem

Was it helpful?

Solution

You can't use include inside of a loop, all of the included script gets run repeatedly. Place include("resizer.php") before the foreach

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top