开发者

CakePHP saving thumbnail image error (unable to open)

I am using WebTechNick's file upload plugin to save images on my CakePHP site. That part is working perfectly. I am working in my projects_controller in the add action I loop through the uploaded files and attempt to create and save thumbnails. The thumbnail creation goes well, but I get this error when trying to save the images to the thumbnail directory.

Unable to open 'files/project_images/thumbs' for writing: Is a directory

my files, project_images, and thumbs are all chmoded to 777 so I dont see why I am getting an "unable to open" error. My full code is below.

for($i=0; $i<=2; $i++){
                $path = 'files/';
                $imageName = $this->Project->Image->read('name', $imageStartingId);
                $fullPath = $path . $imageName['Image']['name'];
                list($width, $height) = getImageSize($f开发者_开发技巧ullPath);
                $ratio = $width/$height;
                $thumbnailHeight = $thumbnailWidth/$ratio;
                //resample
                $imageThumb = imagecreatetruecolor($thumbnailWidth, $thumbnailHeight);
                $image = imagecreatefromjpeg($fullPath);
                imagecopyresampled($imageThumb, $image, 0,0,0,0, $thumbnailWidth, $thumbnailHeight, $width, $height);
                imagejpeg($imageThumb, 'files/project_images/thumbs', 100);
                $imageStartingId--;         
            }

any help is much appreciated. Thanks!


You need to give imagejpeg() a filename, and you've given it only the path, as the error message says. Change it to

imagejpeg($imageThumb, 'files/project_images/thumbs/'.$imageName['Image']['name'], 100);

or whatever you want the filename to be.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜