downloading a file as HTML


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

Hi.
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...

$content=$_SESSION['old_page'];

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

// put the content in the file
echo($content);

// stop processing the page
exit;
}
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: http://richardlynch.blogspot.com/2006/06/php-downloads-content-disposition.html 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

INSERT for date range
Hi all

I have the following table

Code: [Select] `date` date
`day` int(2)
`

how can i make a .gif images for my site
Dear Friends ,

Pls solve my problem , I am starting making new site but i dont know how can i

How to write on database when a link is clicked?
Hi, I have a list of products in a gridview. When the link is clicked currently it takes to an ext

upload photo limits
ive got a upload photo script and im just trying to make more secure currently it limits size and as

SWF image using php?
Hello once again.

My latest en devour requires me to produce an image of a static .swf that i

present value of sequence?
Hi

Please help me to find out the present value of sequence?

Thanks

eregi to preg
Im converting my regex for php 5.3 and I am stuck on the following

Code: [Select]if((eregi(&q

PHP / MySQL Associative Multidimensional Array:
Hello.

I have data in a MySQL Table that adheres to the below: (note, no index, could add if

Help with looping
I have a comma separated list of colors taken from a database ($ICo) and a directory of images named

Sum of Values in an Array
This is probably really simple... but it's been years since I've written anything, so bare with me!<

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