为什么 imagejpeg 无法保存到文件夹?
我已经花了几个小时来解决这个问题,并且我一直在整个网络上试图找到这个问题的解决方案...我在 php 中编写一个缩略图生成器,它应该生成一个灰度图像和一个非灰度图像,但是我一直遇到这个错误。我已经将权限更改为 777 并更改为 nobody 和 admin。只要我用相同的名称覆盖图像,这个函数就可以工作,但由于某种原因它无法存储在文件中。
这是错误:
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);
我也检查了很多次,看看路径是否正确,确实如此。
I've been truble shooting this for hours and i've been all over the web trying to find the solution to this... Im writing a thumbnale generater in php that should generate a gray scale image and a non gray scale, but i've been running into this error. I have already changed my permissions to 777 and chown to nobody and admin. and this function works as long as I over write an image by the same name, but it cannot store in a file for some reason.
here is the error:
imagejpeg() [function.imagejpeg]: Unable to open '/Applications/XAMPP/xamppfiles/htdocs/images
/thumb/rollover' for writing: Is a directory
here is the code i'm working with.
$img = imagecreatefromjpeg($grayscale_path);
imagefilter($img, IMG_FILTER_GRAYSCALE);
imagejpeg($img, realpath($this->gallery_path .'/thumb/rollover/'));
imagedestroy($img);
also i've checked many many times to see if the path is correct and it is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要附加一个文件名,
You need to append a filename,
在 imagejpeg 中,第二个参数不是目录的路径,而是实际文件的路径
您必须在路径末尾添加“filename.jpg”。
in imagejpeg, second parameter is not a path to a dir, but to the actual file
you must add "filename.jpg" at the end of the path.