Hallo allemaal,
is er hier iemand die verstand heeft van thumbnails ?.
Ik probeer namelijk thumbnails te maken van de foto's die worden geupload.
Het zou mooi zijn als ik in mijn foto album thumbnails te zien krijg en als je daar dan op klikt dat dan de foto op ware grootte wordt getoond.
met het script wat ik gebruik worden de foto's wel ge-upload maar geen thumbnails gemaakt.
dit is het script..
<?php
$uniqueID = uniqid();
$valid_formats = array('jpg','jpeg','gif','png','JPG','');
$max_file_size = 5242880;
$path = 'Uploads/Foto/';// Upload directory
$uploadok = 1;
// Loop $_FILES to execute all files
foreach ($_FILES['files']['name'] as $f => $name) {
if (file_exists($path.$name) ) {
$name = $uniqueID.$name ;}
if ($_FILES['files']['size'][$f] > $max_file_size) {
$message = "Het bestand $name is te groot<br><p>";
echo"$message";
$uploadok = 0;
continue; // Skip large files
}
elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){
$message= "Het bestand $name is niet toegestaan, De toegestane formaten zijn 'jpg','jpeg','gif','png'.<br><p>";
echo"$message";
$uploadok = 0;
continue; // Skip invalid file formats
}
else{ // Geen errors, Uploaden.
$image_size = getimagesize($name);
$image_width = $image_size[0];
$image_height = $image_size [1];
$new_size = ($image_width + $image_height) / ($image_width*($image_height/45));
$new_width = $image_width * $new_size;
$new_height = $image_heigt * $new_size;
$new_image = imagecreatetruecolor ($new_width, $new_height);
$old_image = imagecreatefromjpeg ($name);
imagecopyresized ($new_image ,$old_image, 0,0,0,0, $new_width, $new_height, $image_width, $image_height);
imagejpeg ($new_image, $name.'.thumb.jpg');
if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name))
$filenames[] = $name;
}
}
?>
840 views