gpt4 book ai didi

php - 为什么imagejpeg无法保存到文件夹?

转载 作者:行者123 更新时间:2023-12-02 10:49:59 24 4
gpt4 key购买 nike

我已经花了好几个小时不停地拍摄这个照片,而且我在网上一直在尝试找到解决这个问题的方法……我在php中编写了一个Thumbnale生成器,应该生成一个灰度图像和一个非灰度图像,但是我一直遇到这个错误。我已经将我的权限更改为777,并授予任何人和管理员权限。只要我用相同的名称覆盖图像,此功能就可以工作,但是由于某种原因它不能存储在文件中。

这是错误:

imagejpeg() [function.imagejpeg]: Unable to open '/Applications/XAMPP/xamppfiles/htdocs/images
/thumb/rollover' for writing: Is a directory

这是我正在使用的代码。
  $img = imagecreatefromjpeg($grayscale_path);

imagefilter($img, IMG_FILTER_GRAYSCALE);

imagejpeg($img, realpath($this->gallery_path .'/thumb/rollover/'));


imagedestroy($img);

我也检查了很多次,看看路径是否正确。

最佳答案

您需要附加一个文件名,

 header("Content-type: image/jpeg"); 
imagejpeg($img, realpath($this->gallery_path .'/thumb/rollover/filename.jpg'));

关于php - 为什么imagejpeg无法保存到文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7328116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com