If you have used my WordPress readme generator you would have noticed that I have a “Save As” button, which when pressed allows you to download the file which was just generated by the PHP code. (In most browsers this opens the save file as dialog box)
Recently one of the readers of my blog asked me how to do this in PHP and I was about to send him the code snippet. But then I thought of writing a blog article so that it will be useful for others as well.
So here we go.
The code is mostly self explanatory. The important part in the above code snippet is the “content Disposition” header.
Also since we are sending headers to the browser, we should not have started the output before this code executes. Otherwise we might get a “header already sent” error.
- WordPress Developer tools to increase productivity in WordCamp Mumbai
- Email Log WordPress plugin v1.9.1 released
- Email Log WordPress plugin v1.9 released
- How to find if you are on the last page of a multi-page post in WordPress
- Easy Retweet WordPress plugin v3.1 Released
- Creating custom tables with correct Character Set and Collation in WordPress