Force Download PHP

Posted by engineerisaac


Posted on 2 months ago

http://php.net/manual/en/images/e88cefb5c3fca5060e2490b9763c4433-readfile.png
Script:


$file = 'monkey.gif';

if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}



Leave a Comment:
Bill Murry - Posted 29 Minutes Ago.
This is a Test comment.