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);
}
确保开头<?php标签前面没有任何内容 。
check the all tags are closed ( opening and closing). Remove all blank lines from php page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.