Laravel not storing files from request
Solution 1
Sorry for posting my own answer but problem was that by default laravel public disk does not upload to public directory. Settings needed to be changed like this: config/filesystems.php
'public' => [
'driver' => 'local',
'root' => public_path(),
'visibility' => 'public',
],
and then simply:
$path = $request->image->store('storage/uploads','public');
Solution 2
If your filesystems.php configs were default then
$path = $request->image->store('storage/uploads');
saved your files not in storage/uploads but in storage/app/storage/uploads.
And your current accepted answer is not really good because public_path() intended to be used for storing template files not user uploads. According to official docs uploads should be used in storage/ folder with a symbolic link from public/storage/ but not in public/.
Read more in https://laravel.com/docs/5.4/filesystem#the-public-disk
Michael
Updated on June 17, 2022Comments
-
Michael almost 2 years
I got form with file upload named "image". Form is working and i'm getting image but for some reason it's not stored. this is the code I use to store image:
$path = $request->image->store('storage/uploads');
before that I check
$request->hasFile('image')
and later I'm saving $path. Path is successfully saved and when i check it it's really storage/uploads/radnomid but there is no file