doupiai5597 2017-04-21 22:27
浏览 302
已采纳

Laravel 5 - 文件下载失败的问题

I'm new to Laravel 5.4 and I need to download few PDF files from its database. There's an issue downloading the files.

enter image description here

Here is my controller.

 public function download_files(){
    $dowaloads=DB::table('dowanloadable_files')->get();
    return view('dowanload.dowanload', compact('dowaloads'));
}

Here is my view.

 <tbody> 
    @foreach($dowaloads as $download)
     <tr>
      <td>{{ $download->file_title }}</td>
      <td><a href="download/{{ $download->file_name }}" download="{{ $download->file_name }}"> <button type="button" class="btn btn-primary">Dowanload</button></a></td>
      </tr>
    @endforeach

i place all these PDF files in public/download directory as well but this problem not changed. Is this due to no files in the database?

Here is the database screen. enter image description here

Here is my download directory . enter image description here

  • 写回答

1条回答 默认 最新

  • doukeng1922 2017-04-21 22:51
    关注

    You are using wrong folder name use like this, seen in your download folder image.

      <td><a href="/dowanload/{{ $download->file_name }}" download="/dowanload/{{ $download->file_name }}"> <button type="button" class="btn btn-primary">Dowanload</button></a></td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部