Save Full Size & Thumbnail of Picture
Posted: Fri Nov 21, 2008 12:39 pm
I don't know what I'm doing wrong here..
The intention is to save a copy to Images (it does this fine), it also creates the thumbnail fine.. but it won't save the thumbnail. Yes, the directory is set to 777.
The loop needs to stay before each entry can have up to 6 pictures attached to it.
The intention is to save a copy to Images (it does this fine), it also creates the thumbnail fine.. but it won't save the thumbnail. Yes, the directory is set to 777.
The loop needs to stay before each entry can have up to 6 pictures attached to it.
Code: Select all
<?php
header('Content-type: image/jpeg');
while(list($key,$value) = each($_FILES['images']['name']))
{
if(!empty($value))
{
$filename = $value;
$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
$streetaddress=str_replace(" ","",$streetaddress);
$newfilename = $streetaddress."_".$filename;
$add = "photos/$newfilename";
copy($_FILES['images']['tmp_name'][$key], $add);
chmod("$add",0777);
$width = 75;
$height = 75;
list($width_orig, $height_orig) = getimagesize($add);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($add);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, null, 100);
$adding = "photos/thumbs/$newfilename";
copy($_FILES['image']['tmp_name'][$key], $adding);
chmod("$adding",0777);
}
}
?>