downloading a file as HTML

Posted on 16th Feb 2014 07:03 pm by admin

I'm rather confused with forcing a download. I just want to save dynamic content (from $_SESSION[''] data) as a .html file.

The script to do this is a PHP page, but when I click on "download" it downloads as "download.php"

Here's the code:
Code: header("Cache-control: private"); //IE 6 Fix

if (isset($_GET['download']) && $_GET['download']=="true" && isset($_GET['filename']) && $_GET['filename']!="") {

// retrieve content of the file here, e.g. from a database...


// send the header here
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="' . $_GET['filename']);

// put the content in the file

// stop processing the page
It's accessed using: Code: <a href="../outputs/download_as_file.html?download=true&amp;filename=shine_output.html">Download</a>
Any suggestions? I found a good tutorial here: but don't think it'll do what I need to do

No comments posted yet

Your Answer:

Login to answer
73 Like 10 Dislike
Previous forums Next forums
Other forums

Checking if field is empty AND using !is_numeric
Hi lads,

Need to be able to display an error message (using isset?) that says "Cant lea

COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i

Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.

We made a reverse goods movemen

how do I show what a user have selected from a checkbox?
From my code below, how would i show which check boxes have been checked and which radio buttons sel

Cannot Connect to Database
I am writing an application to do annual reviews. I cannot get my script to work. Whenever it runs I

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS

Play Free Quiz and Win Cash