CodeIgniter Forums
imagejpeg function / annoying warning - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: imagejpeg function / annoying warning (/thread-33835.html)



imagejpeg function / annoying warning - El Forum - 09-09-2010

[eluser]Unknown[/eluser]
Hi,

I got this stupid warning, over an over, and i cant find why :
Quote:Message: imagejpeg() [function.imagejpeg]: Unable to open 'gallery/large/' for writing: Is a directory

the code from a controller:
Code:
$toFile = 'gallery/large/';
$image = 'image.jpg';
imagejpeg($image, $toFile, 100);

I use MAMP on MacOS X, and the thing is i got this error only when i use this function in the code igniter scripts ... :-$

This is what i tried before posting here:
- chmod 777 on the large folder
- sudo chown _www large ( to make mamp the owner of the folder )
- use relative and absolute path for the $toFile variable
- use mkdir($toFile, 0777); to create the folder with the script
- i can create and copy other things in the folder from my script, but impossible to use this function ... its a mystery for me.

If anyone have an idea, please give me an hit


imagejpeg function / annoying warning - El Forum - 09-10-2010

[eluser]crikey[/eluser]
Hi,

According to the php manual page for that function http://php.net/manual/en/function.imagejpeg.php the parameters need to be (in order) the image resource (resource), the filename (string), and the quality (int).

So instead of passing the directory to the function, pass a filename:

Code:
$toFile = 'gallery/large/';
$image = 'image.jpg';
$filename = $toFile.$image;
imagejpeg($handle, $filename, 100);

HTH,

Grant