'php - How to upload TAR.GZ file from Laravel
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'));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
