Laravel 5 Force下载PDF文件

Ahm*_*awy 12 php pdf http laravel laravel-5

编辑
我想强制下载laravel 5中的pdf文件.在laravel 4中我使用了以下代码:

        $file= public_path(). "/site-docs/cv.pdf";
    $headers = array(
        'Content-Type: application/pdf',
        'Content-Disposition:attachment; filename="cv.pdf"',
        'Content-Transfer-Encoding:binary',
        'Content-Length:'.filesize($file),
    );
    return \Response::download($file,"Ahmed Badawy - CV.pdf", $headers);
Run Code Online (Sandbox Code Playgroud)

但在laravel 5中不起作用.它出现了这个错误:

Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)
Run Code Online (Sandbox Code Playgroud)

我试过这个:

return response()->download($file);
Run Code Online (Sandbox Code Playgroud)

同样的错误apeared ...我怎么做才能强制下载laravel 5.

我解决了它 - 答案是:

这是服务器的事情.不管怎么说,还是要谢谢你.你只需在php.ini文件中启用此扩展名:php_fileinfo.dll.然后重启服务器.

rdi*_*diz 24

删除标题,它们不是必需的.在L5中,你可以做到

return response()->download($file, "Ahmed Badawy - CV.pdf");
Run Code Online (Sandbox Code Playgroud)

阅读文档.