0

I'm trying to use this php thumbnail generator http://phpthumb.gxdlabs.com/ and i keep getting the error below.

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'Images/uploaded/thumbnails/' for writing: No such file or directory in D:\Data\Websites\wamp\www\StephsSite\PHP\phpThumb\GdThumb.inc.php on line 672

Here's my script

 <?php
        require_once 'PHP/phpThumb/ThumbLib.inc.php';

        $options = array('jpegQuality' => 80, 'preserveAlpha' => true);

        try {
            $thumb = PhpThumbFactory::create('Images/Drew.jpg', $options);
        }
        catch (Exception $e) {
            echo "problems...";
        }

        $thumb->adaptiveResize(200,200)->save('Images/uploaded/thumbnails/');   
?>

and here's some of my file structure testThumb.php/Images/uploaded/thumbnails

Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
Catfish
  • 18,876
  • 54
  • 209
  • 353
  • I don't know if it will help, but I always tend to have problems using relative paths with PHP-GD, I always have to specify everything using an absolute path. – animuson Mar 05 '10 at 04:47

2 Answers2

2

Sorry, I have to ask: does the Images/uploaded/thumbnails/ directory exist?

As a second thought, the error seems to also indicate that it's trying to open the directory for writing. Are you sure that save doesn't need a file name?

In fact, I think it does. From this page:

Saving Images: Saving images is pretty easy. You need only pass the full path to where you wish to save the image (including the file name) the the save function.

So, I would try something like:

<?php
    require_once 'PHP/phpThumb/ThumbLib.inc.php';
    $options = array('jpegQuality' => 80, 'preserveAlpha' => true);
    try {
        $thumb = PhpThumbFactory::create('Images/Drew.jpg', $options);
    } catch (Exception $e) {
        echo "problems...";
    }
    $thumb->adaptiveResize(200,200)->save('Images/uploaded/thumbnails/Drew.jpg');   
?>
paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • Yep. I've checked like 6 times just to make sure – Catfish Mar 05 '10 at 04:48
  • @Catfish, could you perhaps check one more time? No, I'm only kidding :-) See the update, online docs seem to indicate you need the full file name, not just the path. – paxdiablo Mar 05 '10 at 04:51
  • It's because i didn't have a new filename. I just had Images/uploaded/thumbnails when i actually needed something like Images/uploaded/thumbnails/new_name.jpg. Thanks for pointing me to the documentation again so i noticied that. – Catfish Mar 05 '10 at 04:55
0

I suppose you might want to change the path to Windows style, with backslashes instead of forward slashes. Also, since this file will be written by apache user (thats how it works in *nix, not sure about Windows), you may need to make this directory world writeable and see if that works.

s1d
  • 519
  • 4
  • 13
  • From what i've read, in windows you don't set the CHMOD like in unix. Im just trying this on my localhost using WAMPServer2 – Catfish Mar 05 '10 at 04:49
  • True, but even in Windows, if you right click on a directory, it would show permissions. You might want to give that a try. – s1d Mar 06 '10 at 05:20