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 3427312
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:49:16+00:00 2026-05-18T06:49:16+00:00

Is it possible to redirect a page after a readfile()? I tried to use

  • 0

Is it possible to redirect a page after a readfile()?

I tried to use Header, but that doesn’t work. Also the meta redirect doesn’t work either:

header ("Content-Type: application/pdf");

header("Content-Disposition: attachment; filename=$file");
header("Content-Length: $size");

readfile($file_path);  // Giving file to the customer
// header('Location:../checkout.php');  Doesn't work
// echo ('<meta http-equiv="refresh" content="1;url=../checkout.php">');  Doesn't work
  • 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-05-18T06:49:17+00:00Added an answer on May 18, 2026 at 6:49 am

    It’s impossible to output the header after you have output the file. Headers need to go first (hence the name). If you would output the header before you output the file, a browser would be free to ignore the body. I’m not sure what browsers actually do, but I doubt both a redirect and a file download will be initiated simultaneously. One or the other would probably be ignored.

    Basic fact: You cannot output any information apart from what’s necessary for the file download in the same response as the file download. The header of the file download response can only contain information regarding the file, the response body can only contain the file (i.e. no <meta> refreshes or such, those would become part of the file).

    To illustrate, this would be what the browser receives:

    HTTP/1.1 200 OK
    Content-Type: application/pdf
    Content-Disposition: attachment; filename=foo
    Content-Length: 42
    
    woieufhm23umh29… (file contents as binary gibberish) …cQ3985fno1rHtn3f
    qo8923r10d30<meta http-equiv="refresh" content="1;url=../checkout.php">
    

    Everything after the first blank line would be saved as the file contents, including the <meta> tag. You would actually corrupt the file by outputting any additional content there.

    The way this usually works is to present the user with a “download page”, which has an auto-refresh meta tag and/or Javascript, which first initiates the download, then on the second refresh redirects.

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

Sidebar

Related Questions

I've seen that it is possible to redirect users to a specific page after
I want to redircet to another page by meta refresh, but only after all
Possible Duplicate: Get previous page URL after Response.Redirect Suppose in page 1.aspx, if error
I am wondering if it's possible to redirect a user to another page from
Is it possible, if so how(!), to auto redirect a user that doesnt have
Is it possible to use a session variable, then unset it directly after? Example:
I want to redirect users from a certain page after 10 minutes, and as
Is it possible to create a page that redirects to a private page if
Possible Duplicate: How to redirect users to another page? I'm a beginner in the
is that even possible? What I'm currently doing is using this code wherein after

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.