Domanda

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);
}
È stato utile?

Soluzione 2

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top