Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save phannam1412/5dc20012e05fcc9b5a6f5b79c18a2f1c to your computer and use it in GitHub Desktop.
Save phannam1412/5dc20012e05fcc9b5a6f5b79c18a2f1c to your computer and use it in GitHub Desktop.
force browser to download file
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"db.sql\"");
// readfile('db.sql'); // do the double-download-dance (dirty but worky)
print file_get_contents('db.sql');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment