nice thanks!!
its all good but the thumbs dont work?
<?php
function resize($img, $thumb_width, $newfilename)
{
$max_width=$thumb_width; //Check if GD extension is loaded
if (!extension_loaded('gd') && !extension_loaded('gd2')) {
trigger_error("GD is not loaded", E_USER_WARNING);
return false;
}
//Get Image size info
list($width_orig, $height_orig, $image_type) = getimagesize($img);
switch ($image_type)
{
case 1:$im = imagecreatefromgif($img);break;
case 2: $im = imagecreatefromjpeg($img); break;
case 3:$im = imagecreatefrompng($img); break;
default: trigger_error('Unsupported filetype!', E_USER_WARNING); break;
}
/*** calculate the aspect ratio ***/
$aspect_ratio = (float) $height_orig / $width_orig;
/*** calculate the thumbnail width based on the height ***/
$thumb_height = round($thumb_width * $aspect_ratio);
while($thumb_height>$max_width)
{
$thumb_width-=10;
$thumb_height = round($thumb_width * $aspect_ratio);
}
$newImg = imagecreatetruecolor($thumb_width, $thumb_height);
/* Check if this image is PNG or GIF, then set if Transparent*/
if(($image_type == 1) OR ($image_type==3))
{
imagealphablending($newImg, false);
imagesavealpha($newImg,true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $thumb_width, $thumb_height, $transparent);
}
imagecopyresampled($newImg, $im, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
//Generate the file, and rename it to $newfilename
switch ($image_type)
{
case 1: imagegif($newImg,$newfilename); break;
case 2: imagejpeg($newImg,$newfilename); break;
case 3: imagepng($newImg,$newfilename); break;
default: trigger_error('Failed resize image!', E_USER_WARNING); break;
}
return $newfilename;
}
//This stuff is outside of the function. It operates with our images
if(isset($_POST[submit])){
$imgNumb=1; //This the "pointer" to images
$DestinationDir="upimg/"; //Place the destination dir here
$ThumbDir="upimg/thumbs"; //Place the thumb dir here
do{
$Unique=microtime(); // We want unique names, right?
$destination=$DestinationDir.md5($Unique).".jpg";
$thumb=$ThumbDir.md5($Unique).".jpg";
$IMG=getimagesize($_FILES["img$imgNumb"][tmp_name]);
echo resize($_FILES["img$imgNumb"][tmp_name], $IMG[0], $destination);
$imgNumb++;
}
while($_FILES["img$imgNumb"][name]); }?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" >
<input type="file" name="img1"/>
<input type="file" name="img2"/>
<input type="file" name="img3"/>
<input type="submit" name="submit" value="Submit"/>
</form>
</body>
</html>