doupiai5597 2017-04-22 06: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-22 06: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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元