Support the ongoing development of Laravel.io →
Security Eloquent Architecture

Error Message:

      [2016-01-19 14:47:08] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header()' in C:\xampp\htdocs\development\app\filters.php:60
      Stack trace:
      #0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
      #1 {main} [] []

Code:

Controller:

 public function download(){

    $headers = array('Content-Type' => 'text/csv');
     return Response::download('data_download.csv', 'data_download.csv', $headers)->setContentDisposition('inline');

   }

Filter:

 $response->header('Content-Type', 'text');

 $response->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0');

Maybe someone can help me with this.

Last updated 3 years ago.
0

You should use

$response->headers->set('Content-Type' , 'text');
$response->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
0

Sign in to participate in this thread!

Eventy

Your banner here too?

aldrin027 aldrin027 Joined 4 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.