RSS

[php][quick tutorial] Popup for downloading txt file instead of opening it in browser

19 Mar

Here is a simple code for getting the popup for downloading a txt file (or any other file which get opened in the browser).

print file_get_contents(“test_content.txt”);
header(‘Content-Disposition: attachment; filename=”test_download.txt”‘);

line 1, prints the text file content which is to be downloaded.

line 2, make the printed content of the page to be downloaded by showing a popup first.

Note: whatever html and php code is printed in the page will be a part of test_download.txt file content.

Have a nice php ahead 🙂

Advertisements
 
Leave a comment

Posted by on March 19, 2012 in Uncategorized

 

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: