Jump to content

Archived

This topic is now archived and is closed to further replies.

clem_c_rock

Directory permissions problems w/ imagejpeg():

Recommended Posts


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:

[code]
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 );
  }
}
[/code]

Just don't get it.

Clem C

Share this post


Link to post
Share on other sites
You have to give it a name, not just the directory....

so this....

[code]imagejpeg( $thumb, '../', 100 );[/code]

needs to be something like this....

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



me!

Share this post


Link to post
Share on other sites

×

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.