I'm putting together a form to submit images to my photo gallery, and also create thumbnails for those images. The image submission is working great. The images are placed in the correct folder, and data is being written to a mysql table just fine. The resized thumbnail however will not save, and I've changed permissions to all files associated to 777. Any ideas?
Warning: imagejpeg(): Unable to open 'http://myspace.avclan.net/gallery/images/thumb.jpg' for writing in /home/myusername/domains/avclan.net/public_html/myspace/admin/process_image.php on line 20
Code:
function createthumb($src_image_path, $max_width, $max_height) {
$src_img = imagecreatefromjpeg($src_image_path);
$src_x = imagesx($src_img);
$src_y = imagesy($src_img);
$dst_img = imagecreatetruecolor($max_width, $max_height);
imagecopyresampled($dst_img, $src_img, 0, 0, ((x >= y)?(round(.5 * $src_x - $src_y)):0), ((y >= x)?(round(.5 * $src_y - $src_x)):0), 100, 100, min($src_x, $src_y), min($src_x, $src_y));
imagejpeg($dst_img, "http://myspace.avclan.net/gallery/images/thumb.jpg");
}
edited to add:
I googled a bit more and found this:
http://textpattern.com/faq/178/image...ng-a-thumbnail
Q. Warning: imagejpeg(): Unable to access images/2t.jpg in textpattern/lib/class.thumb.php
A. This error messages is probably caused by a bug in PHP 4.4.1. It’s listed as fixed in the PHP 4.4.2 changelog.
Hey Mike, get crackin' on that PHP upgrade!
I've tried every workaround I could find including creating the file first with "fopen", using "touch" turning safemode off before the imagejpeg() function and on again afterward. Nothing works. The permissions are fine because a blank thumb.jpg file is created with fopen. imagejpeg simply does not want to write to the server. The plus side is I know my code is working because I was able to write the image directly to the browser by changing the header content-type to image/jpeg. It seems like my only option here is to wait for a php upgrade and create thumbnails manually until then