Reputation: 3141
I am trying to get the user to download a file.
The error message I'm getting:
Argument 3 passed to Illuminate\Routing\ResponseFactory::download() must be of the type array, null given, called in
My code:
$file = Uploads::where(['username' => $username, 'id' => $id])->firstOrFail();
return response()->download($file->path, $file->name, header('Content-Type', $file->mime));
I have no idea why.
Upvotes: 0
Views: 1629
Reputation: 50481
You are getting that because you are not passing an array as the third argument. header()
is a PHP function for sending a raw HTTP header, it does not return anything.
If you want to use that 3rd argument for download
you would need to pass it an array, but you should try to see if download
method can set the correct headers for you without passing the 3rd argument and if not then pass your own headers.
Upvotes: 1