【问题标题】:failed - server error laravel失败 - 服务器错误 laravel
【发布时间】:2018-07-13 11:43:18
【问题描述】:

我正在尝试在我的应用程序中下载文件但失败 - 服务器问题错误。

这是我认为的网址:

    <a href="{{route('download',$value->file)}}" download="{{$value->file}}" class=" btn btn-info btn-sm">
    <i class="glyphicon glyphicon-download-alt"> Download</i>
    </a>

我的路线:

Route::get('/download/{filename}','HrController@downloadFile')->name('download');

我的下载功能:

public function downloadFile($filename)
    {
           $dwn = storage_path('app\public\upload'.$filename);
            return Storage::download($dwn);
    }

显示我收到的错误消息的图像 link to the image showing the error

【问题讨论】:

  • 你答应的形象呢?向我们显示错误消息。
  • 以某种方式解决了这个问题?

标签: php laravel file download filesystems


【解决方案1】:

您需要创建一个表单才能传输文件。你可以使用 Laravel 集合来创建表单。你可以在这里找到更多信息:

https://laravelcollective.com/docs/5.4/html#file-input

不要忘记在打开表单时添加文件:

{!! Form::open(['url' => 'foo/bar', 'files' => true]) !!}

【讨论】:

  • 我正在下载文件而不是传输
  • 好吧抱歉我没听懂你的回答
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-26
  • 2018-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-29
相关资源
最近更新 更多