小编典典

Laravel `Storage::put()` 在 Unix 服务器上不起作用

php

想将通过图像干预修改的图像保存在我的 Laravel 项目的存储文件夹中。
Storage::put()这工作正常并将图像保存在storage文件夹中(我的本地操作系统是 Windows 10),但在服务器操作系统(CentOS 8)中不起作用。 storage文件夹权限是 755 我试过 777 但也没有用。这是我的代码:

$filename = basename($request->tutorialImage);
$image = Image::make($request->tutorialImage)->resize(300, 400);
$image->stream();
Storage::disk('local')->put('files/shares/resizedImages/' . $filename . '-' . 300 . '-' . 400. '.jpg', $image);

我也已经运行了命令php artisan storage:link


阅读 63

收藏
2022-07-25

共1个答案

小编典典

用这个

chown -R $USER:www-data bootstrap/cache
chown -R $USER:www-data storage
chown -R $USER:www-data resources/views
chown -R $USER:www-data public/files

chmod -R 775 storage
chmod -R 775 bootstrap/cache
chmod -R 775 resources/views
chmod -R 775 public/files
2022-07-25