【发布时间】:2012-10-12 22:24:06
【问题描述】:
<a href="download.php"><img src="images/android/android01.jpg"/>Android</a>
链接到:
php代码:
$file = 'myfile.apk';
$filename ="MYAPP";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.android.package-archive');
header("Content-Disposition:attachment; filename=\"$filename\"");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
我在 Firefox 桌面浏览器和手机上得到一个未定义的输出。当我刷新浏览器时,下载对话框会启动并下载 apk 文件。 关于如何绕过空白页面中未定义的输出并立即进入下载对话框的任何想法?
【问题讨论】:
-
未定义的输出是什么意思?
-
一个空白网页返回,第一行带有未定义的单词..
-
嗯?这很奇怪......只有“未定义”没有别的?
-
在浏览器刷新时只启动下载对话框
-
在其他地方听起来像是一个错误,但在脚本的这一部分中没有。顺便说一句,我建议将 .apk 附加到文件名...