braed's avatar
Level 1

File Upload Store Isn't Working

I am having trouble storing an uploaded file with Laravel 5.7 on Windows.

My file reaches the controller and is being validated. IsValid() returns true.

I'm using Storage::putFile('avatar_files', $request->file('file_avatar')) which is returning a path but not creating a file in the specified folder.

Any ideas?

0 likes
6 replies
braed's avatar
Level 1

Here's my controller (minus some logic that is definitely not affecting my issue):

$this->validate($request, [
    'file_avatar' => 'nullable|file',
]);
        
if ($request->has('file_avatar')) {
    $file_avatar = $request->file_avatar; // this has a type of UploadedFile
    $avatar_path = Storage::putFile('avatar_files', $file_avatar); // this returns a string with a unique file name and path to the correct directory (avatar_files/pkKhjw1GpUGKQbmA8H6djpeFU9j4qrIH1uZqUWqM.jpeg), but the file isn't created
}
Snapey's avatar

but the file isn't created

where are you looking?

braed's avatar
Level 1

where are you looking

public/avatar_files

Snapey's avatar
Snapey
Best Answer
Level 122

and what is in storage/avatar_files

1 like
braed's avatar
Level 1

and what is in storage/avatar_files

Hooray! storage/app/avatar_files contains my Laravel-stored files. Thank you.

Are my files being stored there because the FILESYSTEM_DRIVER environment variable defaults to local?

Is there any reason why I might want to store my files in storage/ and not public/ ?

Edit: I have just read the docs properly!

Please or to participate in this conversation.