-2

在进行 header() 重定向以推送文件以供下载之前,我需要显示一个文本。所以,例如

echo "text";

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');

while (!feof($handle)) {
   echo fgets($handle, $chunksize);
   flush();
}
fclose($handle);

那可行吗?

4

1 回答 1

0

你需要以不同的方式做到这一点。设置一个显示您的文本的简单页面,并通过 javascript 或 HTML 重定向将用户重定向到下载页面。通常浏览器会在新窗口中显示下载提示,您的文本仍会显示。

于 2013-04-28T21:10:20.077 回答