DevTeam
DevTeam

Reputation: 33

how to download file from storage folder in blade page in laravel?

Here is the code:

<a download="MyPdf" href="{{ storage('app/public/file.pdf') }}" title="MyPdf">Download</a>

The file.pdf are in the folder storage/app/public

Upvotes: 1

Views: 9749

Answers (2)

Ahmed Nawaz Khan
Ahmed Nawaz Khan

Reputation: 1806

  1. add url like

    Route::get('get/file', function(){
        return Storage::download('path to file');
    })
    
  2. now hit the url and you will download the file

Upvotes: 0

Bulfaitelo
Bulfaitelo

Reputation: 513

First you need to create a symbolic link

php artisan storage:link

That will create a symbolic link to /storage/app/public

After you need use Storage::url();

Example:

<a download="MyPdf" href="{{ Storage::url('file.pdf') }}" title="MyPdf">Download</a>

With this you will download what is in the /storage/app/public/file.pdf folder

Upvotes: 2

Related Questions