Laravel Uploading File Unable To Write In Directory
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
but still even after that am getting an error
Unable to write in the "/var/www/html/public/system" directory.
I'm using laravel 5 and my host is digital ocean. Thanks
chmod 755 /var/www/html/public/system and
chown www-data:www-data /var/www/html/public/system as stated by @JLPuro works perfectly. Thanks a lot guys.
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?