Jump to content

imagejpeg function / annoying warning


nicosalto

Recommended Posts

Hi,

 

I got this stupid warning, over an over, and i cant find why :

 

Message: imagejpeg() [function.imagejpeg]: Unable to open ‘gallery/large/’ for writing: Is a directory

 

the code :

 

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

 

I use MAMP on MacOS X. :-$

 

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

Link to comment
Share on other sites

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:

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.