开发者

PHP script giving no such file or directory error

开发者 https://www.devze.com 2022-12-22 11:59 出处:网络
I\'m trying to use this php thumbnail generator http://phpthumb.gxdlabs.com/ and i keep getting the error below.

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 {
开发者_JAVA百科            $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


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');   
?>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消