使用 Laravel 8 上传文件时不允许 Chmod() 操作

问题描述

我在 Laravel-8 中上传文件时遇到问题

try {
    foreach ($request->file('images') as $image) {
        $newsImage = new NewsImage();
        $newsImage->news = $request->news;
        $newsImage->path = $image->store('news/'.$request->news);
        $newsImage->save();
}
return redirect()->back()->with('status','Imagens cadasTradas com sucesso!');
} catch (\Exception $exception) {
    return redirect()->back()->withErrors([$exception->getMessage()]);
}

当我运行代码时,它一直运行到第 5 行,代码在该行执行,并按照我想要的方式保存文件,但它抛出异常并停止执行

在例外情况下,消息是

chmod(): Operation not permitted

我不知道问题出在哪里,因为第 5 行有效,但它也抛出异常。

有没有办法不用 Laravel 原生的 store 函数运行 chmod 命令?

我正在使用 WSL 使用 docker for windows。所有文件夹都具有 0777 权限。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)