[英]Force download without losing the format?
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. 从php页面删除所有空白行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.