I've checked out the other posts about this, mine seems to be unique for some reason

基本上,我要做的是将上传的照片存储在公共目录中,以便于访问,但是当我存储它们时,我试图将它们存储在用户特定的文件夹中,所以

/public/photos/$User->id/$filename.jpg

Right now I have Dropzone uploading the file, and I've added to my filesystem.php this statement

'public_uploads' => [
  'driver' => 'local',
  'root'   => public_path(),
],

So in theory when I access that using

Storage::disk('public_uploads') 

它应该检索到正确的路径

这是我的控制器

$User = User::find(Auth::user()->id);
$Photo = Request::file('photo');
Storage::disk('public_uploads')->put("photos/$User->id", $Photo);

Then I get this error from Laravel on upload

{message: "Impossible to create the root directory "/censoredfilesystem/public/Photos/1".",…}

No idea where the period is coming from and any help is greatly appreciated

谢谢大家!

  • 扎克

推荐答案

通过根据 comments 设置权限,我在不知不觉中修复了它

chown -R www-data:root .

in the root of my directory

Edit: I used www-data:root, meaning set the owner of everything inside the Laravel directory to www-data (the webserver) and root being root obviously. If you do this you should do it with a non-root user or just to www-data

Laravel相关问答推荐

使用MAATWebSite/EXCEL导入Exel时,不会创建Laravel模型

如何从@foreach 循环中捕获所有数据并将其传递给 值? - Laravel

从主类别模型 laravel 中获取子类别翻译

如何为 CMP 横幅安装谷歌同意脚本?

如何在laravel中输出奇偶行

如何处理 Laravel 的 SMTP 驱动程序中的自签名 TLS 证书?

带有 Laravel Passport 的 SSO

我怎样才能了解更多关于我的 Laravel 排队作业(job)失败的原因?

在 laravel 中更改时区

如何使用 laravel eloquent 获得select count(*) group by

为什么客户凭证应该与 Laravel Passport 中的用户相关联?

Laravel 5.2 身份验证不起作用

Laravel 说 Auth guard [] 没有定义

Laravel 5.4 有时验证规则不起作用

扩展 Eloquent 的类的构造函数

如何在不使用视图的情况下使用 Laravel 4 发送Electron邮件?

将值插入隐藏输入 Laravel Blade

如何在没有日志(log)、没有信息的情况下调试 Laravel 错误 500

如何访问 Laravel 集合中的第 n 个项目?

Laravel 如何在 Eloquent 模型中添加自定义函数?