Ik had graag thumbnails gemaakt bij het uploaden van mijn afbeeldingen. Maar er zit precies een fout in dit script want er worden geen thumbnails opgeslaan.
Alvast bedankt
Code:
<?php
$destination_dir = "../";
$thumbWidth = "100";
foreach ($_FILES[Imagedata][name] as $key => $value)
{
$uploadfile = $destination_dir . basename($_FILES[Imagedata][name][$key]);
move_uploaded_file($_FILES['Imagedata']['tmp_name'][$key], $uploadfile);
$img = imagecreatefromjpeg($_FILES[Imagedata][name][$key]);
$width = imagesx($img);
$height = imagesy($img);
$new_width = $thumbWidth;
$new_height = floor($height*($thumbWidth/$width));
$tmp_img = imagecreatetruecolor($new_width,$new_height);
imagecopyresized($tmp_img,$img,0,0,0,0,$new_width,$new_height,$width,$height);
imagejpeg($tmp_img, "../thumbs/");
}
?>
Alvast bedankt