close

How to upload files in Laravel directly into public folder?

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error How to upload files in Laravel directly into public folder? in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How to upload files in Laravel directly into public folder Error Occurs?

Today I get the following error How to upload files in Laravel directly into public folder? in php.

How To Solve upload files in Laravel directly into public folder Error ?

  1. How To Solve upload files in Laravel directly into public folder Error ?

    To Solve upload files in Laravel directly into public folder Error I figured out the fix to this issue , in the config/filesystem.php add this line 'default' => 'public', in my case that fixed for me.

  2. How to upload files in Laravel directly into public folder?

    To Solve upload files in Laravel directly into public folder Error I figured out the fix to this issue , in the config/filesystem.php add this line 'default' => 'public', in my case that fixed for me.

Solution 1

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;
}

Solution 2

I figured out the fix to this issue , in the config/filesystem.php add this line 'default' => 'public', in my case that fixed for me.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment