Archive: header

 

Posts Tagged ‘header’


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 [...]



 

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");   [...]