我尝试在我的laravel web项目中制作下载选项。 代码1:
public function downloadLogo()
{ return Response::download(images/logo.png); }
代码2:
$file = public_path()."/images/logo.png";
$headers = array('Content-Type: application/png',);
return Response::download($file, 'logo.png',$headers);
它们都不起作用。有什么想法吗?
答案 0 :(得分:1)
也许为时已晚,但这是实现这一目标的正确方法:
return Response::download( $file , 'logo.png' , array( 'Content-Type' => 'image/png' ) )->setContentDisposition('inline');
答案 1 :(得分:0)
Try this,
$file = "images/logo.png";
$headers = array('Content-Type'=>'application/png');
return Response::download($file, 'logo.png',$headers);