I am trying to download a .tgz file using the following:
$file = '/var/www/upload/myfile.tgz';
if (file_exists($file))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
The problem is that when I 'm trying to extract the downloaded file
with tar
gives me the following error:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
note: this error does not occur when trying to extract the original file.