Howdy all.
Trying to create an image identifier ($src_img) using imagecreatefromjpeg(), and PHP keeps telling me that when I attempt to use $src_img, it is not a valid resource. Here's my code:
The $id passed to the function comes from [FONT=century gothic]$id = mysql_insert_id($link_id)[/FONT] My images are stored in a folder with the format $id_[name of uploaded image].xxx.
function thumbnail($id) {
global $upload_adFullimg_dir, $thumb_w, $thumb_h, $src_img;
$full_img = $_FILES['adFullimg']['type'];
if($full_img == "image/pjpeg"){
$path = "$upload_adFullimg_dir/$id" . "_" . basename($_FILES['adFullimg']['name']);
echo $path;
$src_image = imagecreatefromjpeg($path);
echo "JPG ran.";
echo $src_img; }
else {
$src_image = imagecreatefrompng("$upload_adFullimg_dir$id" . "_" . basename($_FILES['adFullimg']['name']));
echo "PNG ran.";
echo $src_img; }
//Preserve aspect ratio.
//Code courtesy of Christian Heilmann @ http://www.onlinetools.org/articles/creating_thumbnails_all.php
$old_x = imagesx($src_img);
$old_y = imagesy($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
The echo's are my debugging statements. Here's what the output looks like:
ebunny.jpg has been successfully uploaded.
Filesize: 12,385
Filetype: image/pjpeg
path/27_ebunny.jpgmy echo statementJPG ran.
Warning: imagesx(): supplied argument is not a valid Image resource in path/success.php on line 134
Warning: imagesy(): supplied argument is not a valid Image resource in path/success.php on line 135
Warning: imagecopyresized(): supplied argument is not a valid Image resource in path/success.php on line 150
So, I've narrowed it down to the $src_img as being an empty string. I've already tried echoing it, and it is blank.
phpinfo() reports my gd version as 1.6.2 and higher.
Any help would be greatly appreciated.