Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP not download apk file correctly on my server

I must download an apk file from my server, but i have an incomplete download.

This is the code:

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

EDIT

I try this but it not work..

$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;
         }

Sorry for my english but i'm italian ..

like image 217
dvdciri Avatar asked Dec 28 '25 10:12

dvdciri


1 Answers

You Can Try This Maybe Its Help you.............

$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;
}
like image 114
ujash joshi Avatar answered Dec 30 '25 23:12

ujash joshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!