How To Force File Download With PHP

, , , ,

Here is a a simple code that will force the browser to download a file

 <?php
$file = "www.mysite.com/myfile.gif";
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="'.$filename.'";');
download($file);
exit;
?>

Very simple … Don’t forget to subscribe for more tutorials



Comments are closed.