I'm uploading files in my system and it works locally where am using windows and xampp but when hosting where am using an Ubuntu stack my file is not being uploaded. I'm getting an error that it cannot be written in the 'system' directory which is within the public folder. This is my code

 $destinationPath = public_path().'/system'; // upload path
  $extension = Request::file('add_students')->getClientOriginalExtension(); // getting excel extension
  // dd($extension);
  $fileName = rand(11111,99999).'.'.$extension; // renameing excel file
  $file=Request::file('add_students')->move($destinationPath, $fileName); // uploading file to given path
  $path=$file->getRealPath();

after looking for solutions I found out that I should make my directory writable so I ran the following command in putty

chmod 770 /var/www/html/public/system

但即使在那之后,我还是得到了一个错误Unable to write in the "/var/www/html/public/system" directory.

I'm using laravel 5 and my host is digital ocean. Thanks

推荐答案

@JLPuro所说的chmod 755 /var/www/html/public/systemchown www-data:www-data /var/www/html/public/system非常有效.谢谢大家.

Laravel相关问答推荐

当使用Craftable PRO时,Wysiwig是什么时候生成的?

查询Laravel中的图形

Laravel 5.4 - 如何为同一个自定义验证规则使用多个错误消息

Laravel 附加额外字段

Laravel 5.3 auth 判断构造函数返回 false

Laravel - 验证 - 如果字段为空则需要

Eloquent 的 Model::query() 是什么意思?

使用模型工厂、一对一和一对多关系定义 Laravel 外键,而不创建不必要的模型

Laravel 5:完整性约束违规:1452 无法添加或更新子行:外键约束失败

Laravel Artisan CLI 安全地停止守护进程队列工作者

日期验证 - 如何本地化/翻译字符串今天和明天

Laravel 更新语法 - 使用数组更新记录

如何在 laravel 4 中删除文件

今天之前的 Laravel 规则......怎么办

如何在 Eloquent Orm 中实现自引用(parent_id)模型

Laravel Nova 显示用户友好的资源名称

Laravel 更新查询

使用 Carbon 将小时转换为 PM 和 AM

为什么`catch (Exception $e)` 不处理这个`ErrorException`?

laravel:如何获取 eloquent 模型的列名?