Skip to content

Instantly share code, notes, and snippets.

@paperscissors
Last active March 2, 2021 21:41
Show Gist options
  • Save paperscissors/f9d2a57eb949239f5b4db18657610894 to your computer and use it in GitHub Desktop.
Save paperscissors/f9d2a57eb949239f5b4db18657610894 to your computer and use it in GitHub Desktop.
LAravel response macro for file attachment download response
Response::macro('attachment', function ($content, $filename) {
$headers = [
'Content-type' => 'text/plain',
'Content-Disposition' => 'attachment; filename="'.$filename.'"',
];
return Response::make($content, 200, $headers);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment