0
When downloading files or documents through my application, they successfully download, more when opening are corrupted.
//FILE DOWNLOAD
$arquivo = 'C:/teste/arquivo.zip';
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=" . basename($arquivo));
header("Pragma: no-cache");
header("Expires: 0");
header("Content-Length: " . filesize($arquivo));
readfile($arquivo);
test the value returned by readfile, if it is returning FALSE, it has an error in reading the file.
– Júlio Neto
If the file is too large... https://answall.com/questions/320553/problema-ao-tenta-baixararquivos-grandes/320566#320566
– Andrei Coelho
See if you have that https://answall.com/questions/192387/for%C3%A7ar-download-com-php-file-come-corrupted/192417#192417
– user60252
I did so: ini_set ("display_errors", "1"); error_reporting (E_ALL); $file = $_GET["C:/test/1.txt"]; $type="application/txt"; header("Content-Type: ". $type); header("Content-Length: ". filesize($file); header("Content-Disposition: Attachment; filename=". basename($file)); readfile($file); Exit; (The file is small has 2kb)
– danillo.sdd
The txt file has been downloaded.. More the content of the original file is: abcdef : <
– danillo.sdd