Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MohammadAsadi's avatar

How to download apk file on laravel?

Hi

I upload apk file on storage folder and Write this code on controller:

$file = "/home/user/public_html/storage/app.apk";

return response()->file($file ,[

'Content-Type'=>'application/vnd.android.package-archive',

'Content-Disposition'=> 'attachment; filename="app.apk"',

]) ;

now download app but is zip file

How to fix it?

0 likes
6 replies
Kwangggs's avatar

laravel download app .apk but is .apk.zip file. I want fix it, please

vandan's avatar

@mohammadasadi

return response()->download($pathToFile, $name, $headers);

but download() function will tell the client to download the file from the web server so the path of your file must point to “public” folder of your website. But if your files are protected and you want your Laravel application to send the file, then use this snippet

return response()->file($path ,[
		'Content-Type'=>'application/vnd.android.package-archive',
	'Content-Disposition'=> 'attachment; filename="android.apk"',
]) ;

for more details check this link https://stackoverflow.com/questions/37539260/laravel-response-send-android-apk-file

Please or to participate in this conversation.