Jump to content


Photo

Directory permissions problems w/ imagejpeg():


  • Please log in to reply
1 reply to this topic

#1 clem_c_rock

clem_c_rock
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 10 October 2006 - 11:09 PM


Hello,

  I'm trying to create thumbnails w/ the  imagejpeg():  and no matter what directory I try to reference w/ the function and no matter what permissions I give any folder, I still get this error:

Warning: imagejpeg(): Unable to open '../' for writing in /home/content/e/r/i/eric68/html/admin/catalogue/catalogue_admin.php on line 124


here's the function I'm using:

function thumb( $filename, $destination, $th_width, $th_height, $forcefill )
{   
      list( $width, $height ) = getimagesize( $filename );
      $source = imagecreatefromjpeg( $filename );

      #$filename = '../../uploaded_gallery_photos/global_album_photos/25_tn_bgfish.jpg';

      if( $width > $th_width || $height > $th_height )
      {
            $a = $th_width/$th_height;
            $b = $width/$height;

     		if( ( $a > $b ) ^ $forcefill )
     		{
         		 $src_rect_width  = $a * $height;
         		 $src_rect_height = $height;
         		 if(!$forcefill)
         		 {
           			$src_rect_width = $width;
           			$th_width = $th_height/$height*$width;
         		 }
     		}
     		else
     		{
         		 $src_rect_height = $width/$a;
         		 $src_rect_width  = $width;
         		 if(!$forcefill)
         		 {
           			$src_rect_height = $height;
           			$th_height = $th_width/$width*$height;
        		 }
     		}

     		$src_rect_xoffset = ( $width - $src_rect_width ) / 2*intval( $forcefill );
		$src_rect_yoffset = ( $height - $src_rect_height ) / 2*intval( $forcefill );

     		$thumb  = imagecreatetruecolor($th_width, $th_height);
     		imagecopyresized( $thumb, $source, 0, 0, $src_rect_xoffset, $src_rect_yoffset, $th_width, $th_height, $src_rect_width, $src_rect_height );

            echo "<br>thumb-->>$thumb || filename-->>$filename || destination-->>$destination";
     		#imagejpeg( $thumb, $destination );
            imagejpeg( $thumb, '../', 100 );
   	}
}

Just don't get it.

Clem C

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 10 October 2006 - 11:22 PM

You have to give it a name, not just the directory....

so this....

imagejpeg( $thumb, '../', 100 );

needs to be something like this....

imagejpeg( $thumb, '../new_image.jpg', 100 );



me!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users