<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文件。 关于如何在空白页面中解决未定义输出并立即进入下载对话框的任何想法?
答案 0 :(得分:0)
请改为尝试:
<a href="#" onClick="window.location='download.php'">
<img src="images/android/android01.jpg"/>Android
</a>