Upload Laravel file Cannot write to directory

I upload files to my system and it works locally where I use windows and xampp, but when placing where I use the Ubuntu stack, my file does not load. I get a message saying that it cannot be written to the "system" directory, which is located in the shared 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 searching for solutions, I found out that I had to make my directory writable, so I ran the following command in putty

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

but even after that I get an error message Unable to write in the "/var/www/html/public/system" directory.

I am using laravel 5 and my host is the digital ocean. Thanks

+8
source share
2 answers

chmod 755 /var/www/html/public/system chown www-data:www-data /var/www/html/public/system, @JLPuro, . .

+25

sudo chmod 777./(folder name)

sudo chmod 777 -R ./(file name)

+1

Source: https://habr.com/ru/post/1624645/


All Articles