Racoon
Racoon

Reputation: 9

Download any file type from laravel webpage on server

I try to make download option in my laravel web project. Code 1:

public function downloadLogo()
{ return Response::download(images/logo.png); }

Code 2:

$file = public_path()."/images/logo.png";
$headers = array('Content-Type: application/png',);
return Response::download($file, 'logo.png',$headers);

None of them works. Any idea?

Upvotes: 0

Views: 691

Answers (2)

Potsky
Potsky

Reputation: 328

Perhaps too late but here is the correct way to achieve this :

return Response::download( $file , 'logo.png' , array( 'Content-Type' => 'image/png' ) )->setContentDisposition('inline');

Upvotes: 1

Ganesh Jogam
Ganesh Jogam

Reputation: 3151

Try this,

      $file = "images/logo.png";
      $headers = array('Content-Type'=>'application/png');
      return Response::download($file, 'logo.png',$headers);

Upvotes: 0

Related Questions