Open jeremyzahner opened 9 years ago
For now you could do:
public function download($id, Http $http)
{
$post = Post::find($id);
if (!$post) {
return response('Label not found', 404);
}
$file = get_attached_file($id);
$filename = iconv('UTF-8', 'ASCII//TRANSLIT', basename($file));
$headers = [];
$headers['Content-Type'] = "application/pdf";
$headers['Content-Disposition'] = "attachment; filename='{$filename}'";
return response(file_get_contents($file), 200, $headers);
}
It would make sense to have a standard (and better) way of returning a file within the framework.
Thanks!
If i find some time i could probably make a proposal on how to do it.
Hi there
I was trying to serve files via a controller.
Also because of the router restriction i can not directly return my response.
Is there a easy way to get this working?