Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - link to a file saved in storage folder

When we do something like this:

Storage::disk('local')->put('file.txt', 'Contents');

How do you make a link to that file in a view? Something like this:

<a href="path_to_file.txt">Download File</a>

there are so many things in documentation and yet not even one example how to create a link to that file

like image 923
lewis4u Avatar asked Dec 02 '16 16:12

lewis4u


People also ask

How do I access files in Laravel storage?

Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.

What is the use of storage link in Laravel?

This file allows you to configure the disks of any file system. Each disk represents a specific storage driver and location. The local driver interacts with files stored locally on the server running the Laravel application while the S3 driver is used to write to Amazon's S3 cloud storage service.


1 Answers

Try this command on your terminal : php artisan storage:link, then laravel storage become public access.

<a href="{{url('/')}}/{{ Storage::disk('local')->url('file.txt')}}">Download File</a>
like image 131
susilogn Avatar answered Nov 27 '22 06:11

susilogn