I am trying to send a tar.gz file from Laravel as a response, but it is not working properly. What is the error in the code? Here $filepath is the absolute path to the tar.gz file.
if(file_exists($filepath)) {
$file = File::get($filepath);
$response = Response::make($file, 200);
$response->header('Content-Type', mime_content_type($filepath));
$response->header('Content-Length', filesize($filepath));
$response->header('Pragma', 'public');
$response->header('Content-Disposition', 'attachment; filename="sample.tar.gz"');
return $response;
}
else {
return $this->response->array(array('error' => 'Could not be downloaded, try again'));
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/kNUh0Ty
via IFTTT
Aucun commentaire:
Enregistrer un commentaire