Frage

I want to download text file from server to client, the code is working but after I download the text file it shows an extra blank line at top.

How do I remove that line or how do I get the original format of the text file into the client machine?

Here is my code:

$code = $_POST["Code"];
$File = "my$code.txt"; 
if (file_exists($File))
{
    header("Content-Type:text/plain");
    header ("Content-Disposition: attachment; filename=$File");
    header("Content-Length:" . filesize("$File"));
    $fp = fopen("$File", "r");
    fpassthru($fp);
}
War es hilfreich?

Lösung 2

check the all tags are closed ( opening and closing). Remove all blank lines from php page.

Andere Tipps

Make sure there is nothing in front of the opening <?php tag.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top