0

I have a question

How can I make sure when android apk file download trigger, index.php page will remain without being redirected to blank.

index.php page

<head>
    //the javascript loading progress bar to fake simulation how much kb left.
        <script>
            $(document).ready(function() {
                $('body').on('click', '.btn', function(event) {

                    $('#init').hide();
                    $('#progress').show();
                    progress_bar(3210, 'KB');
                });

        });
    </script>
</head>

<body>
<a href="download.php?appid=100&sid=12345" class="btn">Download & Install</a>
</body>



download.php

$appid= $_REQUEST['appid'];
$sid= $_REQUEST['sid'];

if($appid==100)//offer download url
{
    $url= "http://yeahmobi.go2cloud.org/aff_c?offer_id=20374&aff_id=18009&aff_sub=".$sid;

    header("Location: ". $url);
    exit(); 
}

if($appid==111)//offer download url
{
    $url= "url-to-download-that-go-through-double-meta-refresh";

    header("Location: ". $url);
    exit(); 
}

when click download link, chrome will auto download at same page, but firefox will redirect to blank page then a dialog popup appear asking whether to download.

I am looking to make the index.php remain intact, so that the animation simulation download can show clearly to user, while download is triggered.

Any idea guys?

i need help
  • 2,386
  • 10
  • 54
  • 72
  • Have a look here: http://stackoverflow.com/questions/8485886/force-file-download-with-php-using-header – Andy Gee Jun 07 '14 at 10:32
  • Well such a progressbar is not every helpful as long you don't know how many bytes are already downloaded. Or do you count how much bytes are sent? However the code itself looks fine so far... – rekire Jun 07 '14 at 10:34

2 Answers2

0

Call the download.php file with a AJAX request. Just catch the event with JQuery and do the call:

$(document).on("click", ".btn", function(e){
     e.preventDefault();
     //AJAX request
});
S.Pols
  • 3,414
  • 2
  • 21
  • 42
0

You can try using this code. onclick="window.open('filepath_in_server', '_blank', 'fullscreen=yes'); return false;" target="_blank" href="#" in your a href tag.

Nithyanandhan M
  • 1,524
  • 1
  • 16
  • 26