Android Question Download problem

grafsoft

Well-Known Member
Licensed User
Hi,

I know this is not a B4A-problem, but maybe someone can help:

When I transfer an app with B4A Bridge, everyrthing runs perfectly.

When I put it on my server for testers to download, the download is successful, but then I get "Parsing error: An error occured during parsing of the packet".

This is my PHP code:

B4X:
<?php
include ("session.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>A-Tag</TITLE>
<META NAME="Generator" CONTENT="">
<META NAME="Author" CONTENT="Peter Graf">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="style.css">

</HEAD>

<BODY>
<?php
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="main.apk"');
readfile('main.apk');
?>

</body>
 

DonManfred

Expert
Licensed User
I think it should be more like this (WITHOUT html-code and using passthru)
PHP:
<?php
include ("session.php");
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="main.apk"');
header("Content-Length: 11111"); // replace the 11111 with the real apk-size
#readfile('main.apk');
passthru('main.apk',$err);
?>
 

grafsoft

Well-Known Member
Licensed User
Thank, you, but this did not work. With passthru it waits forever, with readfile the problem remains the same :(
 

DonManfred

Expert
Licensed User
maybe this way
PHP:
<?php
include ("session.php");
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="main.apk"');
$apk = file_get_contents('main.apk');
header("Content-Length: ".strlen($apk)); // replace the 11111 with the real apk-size
print($apk);
#passthru('main.apk',$err);
?>
 
Top