tags:

views:

1180

answers:

3

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?

A: 

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));
Greg
var_dump(realpath("../../img/thumbs")); returns bool(false).
Gerardo
From php.net:realpath() returns FALSE on failure, e.g. if the file does not exist.Check the path, try with the absolute path maybe.
DaNieL
+1  A: 

In

/home/user/workspace/stewart/server-side/

the directory

../../img/thumbs/

would equate to

 /home/user/workspace/img/thumbs/

so you need

../../../img/thumbs/
davethegr8
Sorry, made a mistake when writing the question:/home/user/workspace/img/thumbs has its permissions set to 0x777.
Gerardo
A: 

Is there a risk setting the permissions to 0x777 ? I had the same problem and so I had to change the permission from 0x755 to 0x777. Isn't this risky? what is the best approach to solve this problem? a separated Temp directory?

Alex Angelico