Вопрос

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);
}
Это было полезно?

Решение 2

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

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top