views:

176

answers:

2

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

A: 

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
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
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
+1  A: 

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
Yep. I've checked like 6 times just to make sure
Catfish
@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
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