Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload files in Laravel directly into public folder?

The server which I'm hosting my website does not support links so I cannot run the php artisan storage:link to link my storage directory into the public directory. I tried to remake the disk configuration in the filesystems.php to directly reference the public folder but it didn't seems to work either. Is there a way to upload a file using Laravel libraries directly into the public folder or will I have to use a php method? Thanks in advance.

like image 668
Fnr Avatar asked Jun 15 '17 21:06

Fnr


1 Answers

You can create a new storage disc in config/filesystems.php:

'public_uploads' => [     'driver' => 'local',     'root'   => public_path() . '/uploads', ], 

And store files like this:

if(!Storage::disk('public_uploads')->put($path, $file_content)) {     return false; } 
like image 62
sunomad Avatar answered Sep 26 '22 06:09

sunomad