The output file's directory '***' could not be created

1、文件夹的权限我给了755,甚至777都试过了
2、文件夹我就算手动创建好都不行

错误提示

The output file's directory '/uploads/credit/recharge' could not be created
1.  exception: "RuntimeException"
2.  file: "/www/wwwroot/zhaiyanyan.com/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php"
3.  line: 578
4.  message: "The output file's directory '/uploads/credit/recharge' could not be created."

AbstractGenerator.php第578行写的是,这里也是尝试建立文件夹,但是没有权限

if (!$this->isDir($directory) && !$this->mkdir($directory)) {
    throw new \RuntimeException(sprintf(
                'The output file\'s directory \'%s\' could not be created.',
                $directory
            ));

所以,还有可能是什么问题

controller(SnappyImage会自动创建文件夹的)

SnappyImage::loadHtml('***')
                ->setOption('width', 1200)
                ->save('/uploads/credit/recharge/'.Auth::id().'.jpg');
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

/uploads/credit/recharge/ 建议用 public_path 或 storage_path 方法 生成路径吧

4年前 评论
wongvio (楼主) 4年前
讨论数量: 6

是不是用相当于路径了,在不同地方启动,路径也会随之不同。

用绝对路径吧。

    file_put_contents(base_path('1.txt'),'hello');

建议把相关代码丶报错也截屏出来,多一个提示信息,就多一个猜到问题的思路。

4年前 评论

现在问题更神奇了,我用dcat-admin可以在后台上传图片,也可以自动建文件夹

4年前 评论

/uploads/credit/recharge/ 建议用 public_path 或 storage_path 方法 生成路径吧

4年前 评论
wongvio (楼主) 4年前

file
这个路径是从系统根目录开始的。应该用楼上说的那种方法 public_path() 或 storage_path(),这两个方法会生成绝对路径,应该是可以的。;)

4年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!