Hey guys,
i got this problem with a little script im doing. It simply creates a thumbnail on the fly from an image that is uploaded. It works fine on my local testing machine but when i upload it to my server via ftp it doesn't seem to work. This is the error message i get:
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'http://www.mydomainname.com/seanteam/Alistair.jpg' for writing in /home/clovhcom/public_html/seanteam/upload.php on line 180. Here are the snippets of code i think are relevant:
$url = 'http://' . $SERVER['HTTP_HOST'] . dirname($SERVER['PHP_SELF'])."/";
define('THUMBS_DIR', "$url");
// calculate the dimensions of the thumbnail
$thumb_width = round($width $ratio);
$thumb_height = round($height $ratio);
// create an image resource for the thumbnail
$thumb = imagecreatetruecolor($thumb_width, $thumb_height);
// create the resized copy
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
// save the resized copy
switch($type) {
case 1:
if (function_exists('imagegif')) {
$success = imagegif($thumb, THUMBS_DIR.$name.'.gif');
$thumb_name = $name.'.gif';
}
else {
$success = imagejpeg($thumb, THUMBS_DIR.$name.'.jpg', 50);
$thumb_name = $name.'.jpg';
}
break;
case 2:
$success = imagejpeg($thumb, THUMBS_DIR.$name.'.jpg', 100);
$thumb_name = $name.'.jpg';
break;
case 3:
$success = imagepng($thumb, THUMBS_DIR.$name.'.png');
$thumb_name = $name.'.png';
}
I checked all my permissions and made them 0777 but that didn't seem to fix the problem. This script works fine when i write to a directory on my hardrive (c:\etc\etc) but has a problem when i try and refer to the http server. I think this may be root of the problem but i dont know enough about it. Is there any other way to write directly to the server instead of using http? my knowledge in this area isn't too good.
Apologies for the ugly code too, i'm a bit of a newbie.
Thanks for you help in advance
Aj