Hey guys. I'm still workin on a small image manipulation script. So far, it works good. I have most of the code, and the only thing that is left, is to actually get the files created. So I got some help earlier, and now am running into troubles again. Here's some code:
<?php
/*
Some code cut out of here for space
*/
if(is_uploaded_file($tempname)){
$year = $_REQUEST[$yeari];
$cat = $_REQUEST[$cati];
$event = $_REQUEST[$eventi];
$orig_dimensions = getimagesize($tempname);
if($orig_dimensions == false || $orig_dimensions[2] != 2){
die(Error_Image_Type);
}
$orig_width = $orig_dimensions[0];
$orig_height = $orig_dimensions[1];
$image_is_tall = ($orig_height>=$orig_width);
$orig_image = imagecreatefromjpeg($tempname);
$sheight = 75;
$swidth = ceil($orig_width*$sheight/$orig_height);
$lheight = 500;
$lwidth = ceil($orig_width*$lheight/$orig_height);
if($image_is_tall){
$t = $sheight;
$sheight = $swidth;
$swidth = $t;
$t = $lheight;
$lheight = $lwidth;
$lwidth = $t;
}
$small_image = imagecreatetruecolor($swidth, $sheight);
$large_image = imagecreatetruecolor($lwidth, $lheight);
// Directory creation tree here (cut for space)
if(imagecopyresampled($small_image, $orig_image, 0, 0, 0, 0, $swidth, $sheight, $orig_width, $orig_height) === FALSE){
echo Error_Create_Thumb;
}
else{
$new_small = Thumbs_Path."/".$nxtfile.".jpg";
if(imagejpeg($small_image, $new_small, 100) === false){
$small_create = false;
echo Error_Create_New_Thumb;
}
else{
$thumb = "http://www.ridgeswimclub.org/photographs/".$_dir['Year'].'/'.$category.'/'.$evt."/thumbs/".$nxtfile.".jpg";
$small_create = true;
echo New_Thumb_Success;
}
}
if(imagecopyresampled($large_image, $orig_image, 0, 0, 0, 0, $lwidth, $lheight, $orig_width, $orig_height) === FALSE){
echo Error_Create_Large;
}
else{
$new_large = Event_Path."/".$nxtfile.".jpg";
if(imagejpeg($large_image, $new_large, 100) === false){
$large_create = false;
echo Error_Create_New_Image;
}
else{
$photo = "http://www.ridgeswimclub.org/photographs/".$_dir['Year'].'/'.$category.'/'.$evt."/".$nxtfile.".jpg";
$large_create = true;
echo New_Image_Success;
}
}
I get the error on the line that is:
if(imagejpeg($small_image, $new_small, 100)
/* AND */
if(imagejpeg($large_image, $new_large, 100)
The errors returned are:
Warning: imagejpeg(): Unable to open '/public_html/photographs/2005/Construction_Photos/Feb._12/thumbs/0001.jpg' for writing in /home/ridgeswi/public_html/main/scripts/photos/upload.php on line 109
It also says the same for line 125 (the other imagejpeg() line).
Any help and ideas would be appreciated.
~Brett