0

Im trying to download a file, but i keep getting the following error

Type error: Too few arguments to function Illuminate\Http\Response::header(), 1 passed in /home/vagrant/projects/name/app/Http/Controllers/InitialController.php on line 178 and at least 2 expected

The code im using is as follows:

return (new Response($file, 200))
    ->header('Content-Type', 'text/plain')
    ->header('Content-Disposition: attachment; filename="filename.gz"');

It works fine if i leave out the Content-Disposition line, but when i add it i get the error.

Any help would be grand.

Peace!

1 Answer 1

3

because You provide whole header as first argument, should be

->header('Content-Disposition', 'attachment; filename="filename.gz"');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.