Tuesday, October 2, 2012

PHP: Force the browser to download a file instead of opening it


Use the following PHP lines to force the browser to download any file  (ex: HTML file) rather than opening in the browser window


header("Content-type: application/octet-stream");
header("Content-Disposition: attachment;  filename=FILE_NAME"); 
echo file_get_contents("/FILE_PATH");


No comments:

Post a Comment