Problem with file download in php

0

I have the following code to download the file:

set_time_limit(0); // Define o tempo máximo de execução em 0 para as conexões lentas

    $arquivoLocal = "../arquivo/emboss/needle/Resultado/$resultado"; // caminho absoluto do arquivo

    // Verifica se o arquivo não existe
    if (!file_exists($arquivoLocal)) {
        echo "Arquivo não encontrado.";
        exit;
    }

    header('Content-Description: File Transfer');
    header('Content-Disposition: attachment; filename="'.$resultado.'"');
    header('Content-Type: application/octet-stream');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($arquivoLocal));
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Expires: 0');

    readfile($arquivoLocal);

The problem I am is that when I click send, the file that is coming to download is the page view that I am not what I put in the $ locallocal, along with the header where the filesize is ($ locallocal) shows the size of download the view also, I made a print_r (filesize ($ localLocal) before the header and in this print I get the right file size. The problem I am not understanding is that the readfile ($ archivocal) is not downloading the correct file?

    
asked by anonymous 07.08.2017 / 22:58

0 answers