This is 100% working PHP script to download a APK file, or any extension:

<?php
// You can download by package name:
include("dbconfig.php");
if (isset($_GET['app_packageName'])){
	$myApps = mysqli_query($dbconnect, "SELECT * FROM app_table WHERE package_name = '". $_GET['app_packageName'] ."' LIMIT 1");
	$fileName = mysqli_fetch_assoc($myApps)['file_name']; // "file_name" is my field in MYSQL database (example: myApp.apk)
	if (file_exists($fileName)) {
		header('Content-Description: File Transfer');
		header('Content-Type: application/'. $_GET['app_packageName'] .'');
		header('Content-Disposition: attachment; fileName='.basename($fileName));
		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($fileName));
		ob_clean();
		flush();
		readfile($fileName);
		exit;
	}
}
// Place this script where your APK file is located
?>

By this way, you can restrict directly download. And you can count downloaded too.

,

DMCA.com Protection Status


Leave a Reply

Your email address will not be published. Required fields are marked *