Laravel 4 响应::下载->;误差500
在Laravel 4.0中,我试图创建一个pdf的(强制)下载链接,该链接位于Laravel 4 响应::下载->;误差500,laravel-4,http-headers,content-type,laravel-routing,download,Laravel 4,Http Headers,Content Type,Laravel Routing,Download,在Laravel 4.0中,我试图创建一个pdf的(强制)下载链接,该链接位于public/assets/files/cvde.pdf 视图: <a href="curry/cvde">deutsch</a> Route::get('curry/{file}', 'HomeController@downloadCV'); public function downloadCV($file) { return Response::download(public_
public/assets/files/cvde.pdf
视图:
<a href="curry/cvde">deutsch</a>
Route::get('curry/{file}', 'HomeController@downloadCV');
public function downloadCV($file) {
return Response::download(public_path() . '/assets/files/' . $file . '.pdf', array(
'Content-Type'=>'application/octet-stream',
'Content-Disposition'=>'attachment; filename="' . $file . '.pdf"'
)
);
}
控制器方法:
<a href="curry/cvde">deutsch</a>
Route::get('curry/{file}', 'HomeController@downloadCV');
public function downloadCV($file) {
return Response::download(public_path() . '/assets/files/' . $file . '.pdf', array(
'Content-Type'=>'application/octet-stream',
'Content-Disposition'=>'attachment; filename="' . $file . '.pdf"'
)
);
}
我收到一个500错误,浏览器指向public/curry/cvde
我做错了什么?首先,您是否手动检查文件是否可访问?其次,我认为您的请求格式错误:
/**
* Create a new file download response.
*
* @param SplFileInfo|string $file
* @param string $name
* @param array $headers
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public static function download($file, $name = null, array $headers = array())
{
....
}