Okay, so after running into problems with the database insertion of images, I'm using a work around to actually host them as images on the site (in a folder) and call them as regular images. So far I've got the creation of the directories down (easy enough...).
Now my problem is renaming and MOVING the files.
Here's what I'm using:
<?php
#####################
## Manipulate the image
#####################
if(is_uploaded_file($tempname)){
$year = $_REQUEST[$yeari];
$cat = $_REQUEST[$cati];
$event = $_REQUEST[$eventi];
list($orig_width, $orig_height) = getimagesize($tempname);
$theight = (int) (($twidth/$orig_width)*$orig_height);
$lheight = (int) (($lwidth/$orig_width)*$orig_height);
$photo_p1 = imagecreatetruecolor($lwidth, $lheight);
$photo_p = imagecreatefromjpeg($tempname);
if(imagecopyresampled($photo_p1, $photo_p, 0, 0, 0, 0, $lwidth, $lheight, $orig_width, $orig_height) === FALSE){
error('4');
}
else{
$photo = imagejpeg($photo_p1, $tempname, 100);
error('5');
}
$thumb_p1 = imagecreatetruecolor($twidth, $theight);
$thumb_p = imagecreatefromjpeg($tempname);
if(imagecopyresampled($thumb_p1, $thumb_p, 0, 0, 0, 0, $twidth, $theight, $orig_width, $orig_height) === FALSE){
error('6');
}
else{
$thumb = imagejpeg($thumb_p1, $tempname, 100);
error('7');
}
/*
** Cut from here is code to use an FTP
** function to create the folders so I
** am the owner, and not "nobody"
*/
/* 153 */ if(is_dir($tdir)){
/* 154 */ if(rename($thumb, $tdir."/".$nxtfile.".jpg") === FALSE){
/* 155 */ error('8');
}
/* 157 */ else{
/* 158 */ $thumb2 = "http://www.ridgeswimclub.org/".$dir."/".$nxtfile.".jpg";
/* 159 */ error('9');
}
}
else{
$create_thumb_dir = FtpMkdir($dir, $tdir);
if($create_thumb_dir === false){
echo $_dir['Event']." thumbnail folder creation failed.";
}
else{
echo $_dir['Event']." thumbnail folder created.";
}
if(rename($thumb, $dir."/".$nxtfile) === FALSE){
error('8');
}
else{
error('9');
}
}
if(is_dir($dir)){
if(rename($photo, $dir."/".$nxtfile.".jpg") === FALSE){
error('8');
}
else{
$photo2 = "http://www.ridgeswimclub.org/".$dir."/".$nxtfile.".jpg";
error('9');
}
}
else{
$create_event_dir = FtpMkdir($cdir, $dir);
if($create_event_dir === false){
echo $_dir['Event']." folder Creation failed.<br />";
}
else{
echo $_dir['Event']." folder Created.<br />";
}
if(rename($photo, $dir."/".$nxtfile.".jpg") === FALSE){
error('8');
}
else{
error('9');
}
}
The only trouble is the actual manipulation of the images. What am I missing?
Output during testing:
Warning: rename(1,/home/ridgeswi/public_html/photographs/2004/Lifeguards/Catie_Easterday/thumbs/0001.jpg): No such file or directory in /home/ridgeswi/public_html/main/scripts/photos/upload.php on line 154
Renaming the file failed!!
Warning: rename(1,/home/ridgeswi/public_html/photographs/2004/Lifeguards/Catie_Easterday/0001.jpg): No such file or directory in /home/ridgeswi/public_html/main/scripts/photos/upload.php on line 173
Renaming the file failed!!
Any help is appreciated.
Also, should this be in a new thread? I dont' think so, but just let me know....
~Brett