Php - Download files by application become corrupted

0

When downloading files or documents through my application, download successfully, more when opening are corrupted.

// DOWNLOAD OF THE FILE

$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);
    
asked by anonymous 08.08.2018 / 22:37

2 answers

0

The txt file has been downloaded ..

More content from the original file is: abcdef

And what you downloaded when you open is:

    
09.08.2018 / 17:08
0

I did so:

ini_set ("display_errors",  "1"); 
    error_reporting (E_ALL);
    $arquivo = $_GET["C:/teste/1.txt"];
      $tipo="application/txt"; 

      header("Content-Type: ".$tipo);
      header("Content-Length: ".filesize($arquivo));
      header("Content-Disposition: attachment; filename=".basename($arquivo));
      readfile($arquivo);
      exit;

(The file is small has 2kb)

    
09.08.2018 / 16:52