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

  • SEARCH
  • Home
  • 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 211209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:04:29+00:00 2026-05-11T18:04:29+00:00

I have a PHP app that creates a CSV file which is forced to

  • 0

I have a PHP app that creates a CSV file which is forced to download using headers. Here’s the relevant part of the code:

header('Content-Type: application/csv'); 
header("Content-length: " . filesize($NewFile)); 
header('Content-Disposition: attachment; filename="' . $FileName . '"'); 
echo $content;
exit(); 

What I’d like to do is redirect users to a new page after the file is built and the download prompt is sent. Just adding header("Location: /newpage") to the end didn’t work, expectedly, so I’m not sure how to rig this up.

  • 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-11T18:04:29+00:00Added an answer on May 11, 2026 at 6:04 pm

    I don’t think this can be done – although I am not 100% sure.

    The common thing (e.g. in popular download sites) is the reverse: first you go to the after page and then the download starts.

    So redirect your users to the final page that (among other things) says:

    Your download should start automatically. If not click [a href="create_csv.php"]here[/a].

    As about initiating the download (e.g. automatically calling create_csv.php) you have many options:

    • HTML: [meta http-equiv="refresh" content="5;url=http://site/create_csv.php"]
    • Javascript: location.href = 'http://site/create_csv.php';
    • iframe: [iframe src="create_csv.php"][/iframe]
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my (PHP) web app, I have a part of my site that keeps
I have a LAMP (PHP) web app which need to interface with programs on
I'm using the data mapper pattern in a PHP app I'm developing and have
I have a .ini file with sensitive information in my php wab app. I
I have an app using PHP and the PayPal API. The basic way it
I have written a web app in PHP which makes use of Ajax requests
We are running a PHP (zend framework) app that creates a database per user
I have a new web app that is packaged as a WAR as part
I have a (custom) php framework that contains following structure: app |-classes |-settings core
I have an app that I'm porting from PHP/symfony to Ruby/Rails. Though the language

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.