繁体   English   中英

警告:imagejpeg()[function.imagejpeg]:无法打开[filename]进行写入:没有这样的文件或目录

[英]Warning: imagejpeg() [function.imagejpeg]: Unable to open [filename] for writing: No such file or directory

我无法弄清楚为什么我在尝试使用imagejpeg()保存图像时收到此错误

下面是我的代码的摘录,我已经删除了任何无关的东西,并保持足够产生错误。 路径肯定存在,并且权限设置为777。

$url = "http://website.com";
    $filename = 'imagename';

    $filepath = $url."/Images/accents/generated/".$filename.".jpg";

    $base = imagecreatefromjpeg($url.'/images/'.$filename);
    $imagewidth = imagesx($base);
    $imageheight = imagesy($base);

    $new = imagecreatetruecolor($imagewidth, $imageheight);

    imagecopy($new, $base, 0, 0, 0, 0, $imagewidth, $imageheight);

    imagejpeg($new, $filepath);

    imagedestroy($new);

`

这可能是因为您尝试输出到url而不是本地文档...

你的输出路径:

http://website.com/Images/accents/generated/imagename.jpg

这不起作用...输出必须是本地的,尝试类似于:

./Images/accents/generated/imagename.jpg

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM