Avyakt
Avyakt

Reputation: 313

PHP Android how to dowload apk file

I have Android app on my server and also have php code like:

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

My mobile with default web browser is downloading this file in the way of reading apk file on the screen. I expected some kind of dialogue like: save it as or/and where do you want to save it instead. What I am doing wrong? Is there any way to save it automatically, meaning without any dialogue?

Upvotes: 0

Views: 7332

Answers (2)

rogcg
rogcg

Reputation: 10471

you should try one of these:

  1. check the mime type configuration on your server. APK Files
  2. add the apk extension to apache

also, check this question. However the server is .net, not php.

Upvotes: 0

Mike Mackintosh
Mike Mackintosh

Reputation: 14245

Try:

header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-Type: application/vnd.android.package-archive');
header("Content-Transfer-Encoding: binary");    
header('Content-Disposition: attachment; filename="test.apk"');
readfile('C4A.apk');

Upvotes: 1

Related Questions