When trying to save a thumbnail made with GD
imagejpeg($tnImage, "../../img/thumbs/".$maxWidth."x".$maxHeight."_".$filename);
I am getting the following error:
Warning: imagejpeg() [function.imagejpeg]: Unable to open '../../img/thumbs/80x80_55865-drops.jpg' for writing: No such file or directory in /home/user/workspace/stewart/server-side/libImg.php
/home/user/workspace/img/thumbs has its permissions set to 0x777.
What can be wrong here?
Where are you running the file from? If it's from the server-side
directory then I think you're missing a "../"
Try this:
var_dump(realpath("../../img/thumbs/".$maxWidth."x".$maxHeight."_".$filename));
In
/home/user/workspace/stewart/server-side/
the directory
../../img/thumbs/
would equate to
/home/user/workspace/img/thumbs/
so you need
../../../img/thumbs/
A workaround for this is providing the imagejpeg
with the full path to the file.
So you can have in config.php
something like
define('APPLICATION_PATH', dirname(__FILE__));
Then in your functions.php call imagejpeg like this:
@imagejpeg($image, APPLICATION_PATH . '/uploads/myfile.jpg', $quality);
来源:https://stackoverflow.com/questions/757008/php-gd-imagejpeg-unable-to-open