Force Download PHP

Posted by engineerisaac


Posted on 4 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;

}






Guests Cannot Post!

If you would like to Comment on this video! Consider joining the Blue community!

Register Login


Other Engineerisaac Articles