PHP 无法在我的服务器上正确下载 apk 文件

标签 php file download apk

我必须从我的服务器下载一个 apk 文件,但我的下载不完整。

这是代码:

header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="Zappapp1.0.apk"');
readfile('Zappapp1.0.apk');

编辑

我试过了但是没用..

$file = 'zappapp.altervista.org/apk/Zappapp1.0.apk';
        if (file_exists($file)) {
             header('Content-Description: File Transfer');
             header('Content-Type: application/vnd.android.package-archive');
             header('Content-Disposition: attachment; filename='.basename($file));
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
             header('Content-Length: ' . filesize($file));
             ob_clean();
             flush();
             readfile($file);
             exit;
         }

抱歉我的英语不好,但我是意大利人..

最佳答案

你可以试试这个也许对你有帮助................................

$file = '/home/bla-bla/domains/bla-bla.com/file/file.apk'; //not public folder
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/vnd.android.package-archive');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}

关于PHP 无法在我的服务器上正确下载 apk 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22267692/

相关文章:

android - 在后台下载大文件 (Android)

Android:直接从浏览器下载文件

php - 通过 php/linux 在服务器之间同步资源的安全方法

php INSERT INTO 数据库变量名

file - 如何将一系列命令的输出重定向到 stdout 和 Tcl 中的文件?

iphone - 如何在iO中将下载的文件另存为只读

scala - 如何使用Scala从Internet下载和保存文件?

php - 仅获取所有父 WooCommerce 类别

php - aws ubuntu实例php最大文件上传不变

java - 我的计数器没有增加并且在java中保持为1