通过下载链接<a> tag in Laravel

时间:2018-11-02 17:20:41

标签: laravel

Here is my code for download link

    @foreach($downloads as $down)
    <tr>
                        <td>{{$down->name}}</td>
                        <td>{{$down->created_at}}</td>
                        <td>{{$down->Subject}}</td>
                        <td>
<a href="public\documents\{{$down->file}}" download="{{$down->file}}">


                            <button type="button" class="btn btn-primary">
                            <i class="glyphicon glyphicon-download">
                                Download
                            </i>
                            </button>
                        </a>
                        </td>
                    </tr>
                @endforeach
                </tbody>

This is my code i make download link for download documents but when i click on download button it failed to download. i retrieve the data from database.I make one section of upload documents and it successfully upload and path on database table and documents in laravel project public\documents But it failed to download when i click on upload button

enter image description here

下载失败

预先感谢

1 个答案:

答案 0 :(得分:1)

  1. URL中的目录不使用正斜杠。

  2. Web文档的根目录应该是公共目录。因此,您不应在网址中使用public作为前缀。

  3. 您还使用了相对URL而不是根相对URL或绝对URL,这可能会出现问题,具体取决于您在何处显示此链接。