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 🙂

 
Leave a comment

Posted by on March 19, 2012 in Uncategorized

 

Tags: , , , , , ,

Leave a comment