简体   繁体   English

如何从laravel刀片页面的存储文件夹中下载文件?

[英]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 file.pdf位于文件夹storage / app / public中

  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 现在点击网址,您将下载文件

First you need to create a symbolic link 首先,您需要创建一个符号链接

php artisan storage:link

That will create a symbolic link to /storage/app/public 这将创建一个指向/storage/app/public的符号链接

After you need use Storage::url() ; 需要使用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 这样,您将下载/storage/app/public/file.pdf文件夹中的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM