I can not figure out in any way which headers to send, so that the archive comes not broken and files are normally extracted from it. At the moment I tried many options, one of them is this:
header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit;
Even if you dynamically substitute the mime type, the file is not extracted from the archive.
There is such an example:
$file = '/path/do/filename.txt'; // или любое др расширение $filename = 'имя которое увидит юзер.txt'; // расширение тут обязательно header ('Content-Type: application/octet-stream'); header ('Accept-Ranges: bytes'); header ('Content-Length: '.filesize($file)); header ('Content-Disposition: attachment; filename='.$filename); readfile($file); exit();
Advise how to be?