Skip to content
Advertisement

how to set header in laravel before firing a download

I want to set headers before firing a download.

Before I used to do something like this in plain php:

JavaScript

Now I want to still be able to set the same headers and call the laravel download function and pass my headers, something like:

JavaScript

where the $headers variable should contain my header’s. Anybody who has ever done this.

Advertisement

Answer

From the docs

You may use the header method to add a series of headers to the response before sending it back to the user:

JavaScript

Or, you may use the withHeaders method to specify an array of headers to be added to the response:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement