Laravel无法创建根目录 [英] Laravel Impossible to Create Root Directory

查看:1835
本文介绍了Laravel无法创建根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经查看了有关此内容的其他帖子,由于某种原因,我的帖子似乎很独特

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

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

Essentially what I'm trying to do is store uploaded photos in the public directory for easy access, however when I store them I'm trying to store them in a user specific folder, so

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

现在,我已经让Dropzone上传了文件,并且我将该语句添加到了filesystem.php中.

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(),
],

从理论上讲,当我使用

Storage::disk('public_uploads') 

它应该检索正确的路径

这也是我的控制器

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

然后我在上传时从Laravel收到了这个错误

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

谢谢!

  • 扎克

推荐答案

通过根据我的评论设置权限来未知地修复了该问题,

Fixed it unknowningly by setting permissions according to comments, I used

chown -R www-data:root .

在我的目录的根目录中

这篇关于Laravel无法创建根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆