If you have a controller action that is designed to be accessed by AJAX requests or perhaps as part of a custom API system then you might like this snippet. If you are working with the above scenario you likely would like to return pure JSON without any HTML etc. Also serving up the correct [...]
Archive: header
Posts Tagged ‘header’
February 15, 2012
No Comments
January 23, 2012
No Comments
If you want to serve up text files for download (perhaps product feeds etc) then you might like this little snippet. Not only will it force the file to be downloaded but it allows you to specify a custom filename that it should be saved as. PLAIN TEXT PHP: if(isset($_GET['download_file'])){ header("Content-type: application/octet-stream"); [...]
Categories:
Archive by date: