Android Question Download problem

Discussion in 'Android Questions' started by grafsoft, Apr 7, 2015.

  1. grafsoft

    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:

    Code:
    <?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>
     
  2. DonManfred

    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 likes this.
  3. grafsoft

    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 :(
     
  4. DonManfred

    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);
    ?>
     
    grafsoft likes this.
  5. grafsoft

    grafsoft Well-Known Member Licensed User

    Thankk you, but same result.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice