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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:24:13+00:00 2026-05-18T10:24:13+00:00

Update #1 What has been posted below is spot on for getting it to

  • 0

Update #1

What has been posted below is spot on for getting it to output the file. What it is doing though is outputting the string data followed by the rest of the forms HTML. Is there any way to stop what is put into the file and what is just displayed to the browser.

Update #2

Just added exit() and all works fine. Thanks!

EOU

Hi,

I’ve been looking around and seen a few things similar but not quite fully got the grasp on what I need to do to achieve the task fully.

At the moment I have a form that a user supplies some details. On submit it is posted back to itself and the POST variables processed. I have a premade HTML web template for the information to be placed into which works fine and dandy just doing a str_replace.

What I am trying to do now is export that as a download to the user in a plain text document. So the end result being the user clicks submit on the form and they then have a download popup open with the modified webpage as a .txt file.

As far as I understand I need to do something using HTTPs headers functionality. What exactly though to achieve what I want I’m not sure. I only want the file to be available once, but I assume it has to be stored somewhere initally for the user to download which will then need cleaing up after manually?

Any help or points would be great! Thanks.

  • 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-18T10:24:13+00:00Added an answer on May 18, 2026 at 10:24 am

    No need to store it anywhere. Just output the content with the appropriate content type.

    <?php
        header('Content-type: text/plain');
    ?>Hello, world.
    

    Add content-disposition if you wish to trigger a download prompt.

    header('Content-Disposition: attachment; filename="default-filename.txt"');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
UPDATE As Mathias notes below, this exact problem has been reported and resolved here:
I know the question has been posted before, not answered thoroughly though. Also I
UPDATE It looks like this problem has been quietly fixed in iOS 4.3. Up
A list of every update and hotfix that has been installed on my computer,
Update II Problem Solved but Why? This has been the biggest headache ever. My
I am trying to update the database to show that something has been uploaded.
Is there any way to update a table layout after it has been created?
I know the question of how to update multiple tables in SQL has been
I know this kind questions has been posted here many times, for exmaple: Java

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.