Hi

I'm getting an error message :

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'keyword-c5c70867b2d4cff7.jpg' for writing: Permission denied in etc/new-site/includes/class.upload.php on line 287

it's part of an image upload - the image uploads ok and then i change its name - the problem comes when i try to resize it using

		if($doResize==1){

		$dst_img=ImageCreateTrueColor($exe_w,$exe_h);			

		imagecopyresampled($dst_img,$src_img,0,0,0,0,$exe_w,$exe_h,$old_w,$old_h); 

		if (preg_match("/png/",$system[1])){
			imagepng($dst_img,$name); 
		}else{
			imagejpeg($dst_img,$name); 
		}
		imagedestroy($dst_img); 
		imagedestroy($src_img);
	}

the line that's causing the error is

imagejpeg($dst_img,$name);

so i guess it doesn't have the right permissions but i can't see how to do a chmod on it - i tried

			chmod($dst_img, 0777);
			if (preg_match("/png/",$system[1])){
				imagepng($dst_img,$name); 
			}else{
				imagejpeg($dst_img,$name); 
			}

but that just said that the file didn't exist

has anyone got any ideas ???

thanks

    The file doesn't exist until you call imagejpeg($dst_img,$name) and thus you cannot change permissions. Make sure the user your web server is running under has permission to write to the folder where you want to place the new image. If you don't know, you can do a phpinfo() and look under apache2handler for User/Group. Depending on whether you have shell access to your account, you will need to change permissions for that directory. If this is not your own server, ask your friendly support staff to kindly help you do this.

      hi

      thanks for your reply

      In phpinfo > user/group it says

      www-data(33)/33

      is that good ? or bad ?

        and when it says that it can't open the file : premission denied, could it be caused by something else other then permissions on the directory ?

          Neither good nor bad, just the apache user (sounds like you've got a debian or ubuntu box.) Now either make sure www-data can write to that folder...

          $ sudo chown www-data /thefolder
          $ sudo chmod 755 /thefolder

          ...or make it writeable by everyone...

          $ sudo chmod 777 /thefolder
            steamPunk;10893728 wrote:

            and when it says that it can't open the file : premission denied, could it be caused by something else other then permissions on the directory ?

            Probably not, usually permission errors are related to OS file permissions.

              ok found it

              it needed the path to the file :

              imagejpeg($dst_img,$destPath.$name);

              thanks 🙂

                Write a Reply...