Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9230287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:47:17+00:00 2026-06-18T05:47:17+00:00

I am using this little pusher php file to download an ‘exe’ file for

  • 0

I am using this little pusher php file to download an ‘exe’ file for the user to save when they fill-out a form.

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);

with this method there is no link to the online $file location for someone to follow but for some reason I cannot display a thank you page after or even immediately before the code is executed.

I’ve tried header( “Location: $thankyouurl” ); immediately after the above code, but nothing is ever displayed and I’ve tried echoing the html source of the thank you page just prior to running the above code, but that causes the exe file to be downloaded to the web page actually crashing the browser.

Any suggestions???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:47:19+00:00Added an answer on June 18, 2026 at 5:47 am

    Point the user directly to a static page that displays your thank you message. Then, use JavaScript to set the window.location to your download script.

    If your download page’s headers are set up correctly, the browser will start downloading the file, while your user is reading your thank you message.

    Make sure to display a direct download link in case the user has JavaScript disabled.

    Example:

    index.php

    <a href="thankyou.php">Click here to download.</a>
    

    thankyou.php

    <html>
    <head>
        <script type="text/javascript">
            function startDownload() {
                window.location = "/download.php";
            }
        </script>
    </head>
    <body onload="startDownload();">
        <h1>Thank you!</h1>
        <p>Your download will start in a moment. If it doesn't, use this <a href="download.php">direct link.</a></p>
    </body>
    

    download.php

    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    

    Update

    In order to pass data from index.php on to the download script, you could use GET variables. The link to the thankyou.php page would become thankyou.php?download=12 where download is an ID for you to grab the correct file. You would then pass that variable on to your download script by echoing it out in your markup like so:

    index.php

    <a href="thankyou.php?download=12">Click here to download.</a>
    

    thankyou.php

    <html>
    <head>
        <script type="text/javascript">
            function startDownload() {
                window.location = "/download.php?file=<?=$_GET['download']?>";
            }
        </script>
    </head>
    <body onload="startDownload();">
        <h1>Thank you!</h1>
        <p>Your download will start in a moment. If it doesn't, use this <a href="download.php?file=<?=$_GET['download']?>">direct link.</a></p>
    </body>
    

    You’d then grab the value in your download script and handle it any way you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this little script to find out whether Firebug is open: if
In my Google Chrome extension, I'm using this nifty little trick to distinguish the
Using series.add(180, 1); produces a perfectly valid chart like this (little red dot at
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes
I would like a little confirmation that I'm doing this correctly. Using rails single
Using this to load the json var jsonParsed = JSON.parse(localStorage.getItem('test')); Using this to save
I've been using this little snippet to select random images. However I would like
I've been struggling with this for a little while now.. I am using this
I'm using this little jewel of a Django code snippet to edit a ManyToManyField
I am using this little script to toggle classes of an element on click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.