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

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top