I have a laravel app in production DigitalOcean VPS with ubuntu and LEMP , web works perfectly but it seems I can't upload files from my web, when I try to upload image via ajax I get the following error (only in production, local works right):
message fopen(/var/www/luisaldada.com/public/uploads/file-25-05-2019-21-39-MAL-421.jpeg): failed to open stream: Permission denied
exception ErrorException
file /var/www/luisaldada.com/vendor/league/flysystem/src/Adapter/Local.php
line 158
This looks like an obvious permission error but I already gave write perm recursively to laravel storage folder, I'm using laravel public/local disk to upload files into an upload folder inside public.
filesystems config file:
'public' => [
'driver' => 'local',
'root' => public_path(),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Maybe it has something to do with public folder not having correct permissions to upload/write?
This are my permisions for laravel folder, as you can see I have gone as far as to set ACL for storage folder.
https://i.imgur.com/LLYIECc.png
This is how I upload file in contrller just in case:
$file = $request->file($name);
$filename = 'file-'.Carbon::now()->format('d-m-Y-H-i').'-'.str_random(3).'-'.mt_rand('000','999').'.'.$file->extension();
$file->storeAs('uploads', $filename);