PHP Android how to dowload apk file

Avyakt picture Avyakt · Aug 20, 2012 · Viewed 7k times · Source

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?

Answer

Mike Mackintosh picture Mike Mackintosh · Aug 20, 2012

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');