[英]homestead laravel 5 : link Download file from storage
i am need hint link to download upload file, currently i am following this answer here is my code 我需要提示链接来下载上传文件,目前我正在关注此答案,这是我的代码
Routes file : 路线文件:
Route::get('getDownload/{remind_letter}',
['as'=>'downloadData',
'uses'=>'DockController@getDownload']);
Controller File : 控制器文件:
public function getDownload($remind_letter)
{
$download = Dock::where('remind_letter','=',$remind_letter)->firstOrFail();
$file =Storage::disk('local')->get($download->remind_letter);
return (new response($file))->header('Content-Type', $entry->m1);
}
result file 结果文件
<div class="row">
<div class="form-group">
<div class="col-xs-5">
<label class="col-sm-7">Remind Letter :</label>
<input type="text" name="remind_letter" value="{{$getData->remind_letter}}">
</div>
<div><a href="{{ route('downloadData',$getData->remind_letter) }}">
<button class="btn btn-success btn-sm">Download</button></a></div>
</div>
</div>
and the result link dock.start/star/getDownload/home/vagrant/Code/dock/storage/app/25/JTK/2015/Renewal License Kaspersky/Moonarch Security/tmp/phpQaGzoD.pdf
以及结果链接
dock.start/star/getDownload/home/vagrant/Code/dock/storage/app/25/JTK/2015/Renewal License Kaspersky/Moonarch Security/tmp/phpQaGzoD.pdf
but the link is always show up error 404 and i can't download file 但链接始终显示错误404,我无法下载文件
FYI when upload file i am using storage_path()
function 仅供参考,当我使用
storage_path()
函数上传文件时
它修复了我的错误逻辑,当上传文件时,应该使用getFilename()
函数, $entry->filename = $filename->getFilename().$extension;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.