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

dvd*_*iri 0 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');
Run Code Online (Sandbox Code Playgroud)

编辑

我尝试了这个,但是没有用。

$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;
         }
Run Code Online (Sandbox Code Playgroud)

对不起,我的英语但是我是意大利人..

uja*_*shi 5

您可以尝试一下,也许可以帮到您.............

$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;
}
Run Code Online (Sandbox Code Playgroud)