How to access uploaded files?

Posted 4 months ago by malhayek

I am trying to allow my users to upload files.

I am using the following code to save the uplaoded file

$file->store('uploads', config('filesystems.default'))

The files are getting uploaded to storage/app/uploads as expected.

But I am unable to access the uploaded files.

In my views I am using the following to show the URL for the attachment

{{ asset('storage/uploads/d4PH5XJ1wU165nN5EQXzDcxBCvgmAn5p1uRGIrCJ.txt') }}

the above code returns the following

http://domain.com/storage/uploads/d4PH5XJ1wU165nN5EQXzDcxBCvgmAn5p1uRGIrCJ.txt

I ran the php artisan storage:link command which created the symbolic link. However, that link returns the following error

NotFoundHttpException in RouteCollection.php line 179:

How can I correctly expose the uploaded file to the public?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.