【问题标题】:Apk download with php gives undefined but download works after browser refresh使用 php 下载的 Apk 未定义,但在浏览器刷新后可以下载
【发布时间】: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 附加到文件名...

标签: php apk


【解决方案1】:

试试这个:

<a href="#" onClick="window.location='download.php'">
  <img src="images/android/android01.jpg"/>Android
</a>

【讨论】:

    猜你喜欢
    • 2021-01-22
    • 1970-01-01
    • 2018-02-14
    • 2017-10-02
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2018-12-29
    相关资源
    最近更新 更多