Skip to content

Instantly share code, notes, and snippets.

@Sanix-Darker
Last active September 23, 2017 20:47
Show Gist options
  • Save Sanix-Darker/b7218bf205105f14c2d2669b8d75bd80 to your computer and use it in GitHub Desktop.
Save Sanix-Darker/b7218bf205105f14c2d2669b8d75bd80 to your computer and use it in GitHub Desktop.
[PHP] Force a download of a file
<?php
if(isset($_REQUEST['src'])){
$file_name = $_REQUEST['src'];
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"".$file_name."\"");
readfile('../Your_Path_Here/'.$file_name);
exit;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment