Skip to content

Instantly share code, notes, and snippets.

@arkenidar
Last active February 23, 2019 20:38
Show Gist options
  • Select an option

  • Save arkenidar/3027115421d08c2b89701a8522756b88 to your computer and use it in GitHub Desktop.

Select an option

Save arkenidar/3027115421d08c2b89701a8522756b88 to your computer and use it in GitHub Desktop.
<?php
$path='download.php'; // CHANGE IT
$finfo = finfo_open(FILEINFO_MIME_TYPE);
header('Content-Type: '.finfo_file($finfo, $path));
$finfo = finfo_open(FILEINFO_MIME_ENCODING);
header('Content-Transfer-Encoding: '.finfo_file($finfo, $path));
header('Content-disposition: attachment; filename="'.basename($path).'"');
readfile($path); // do the double-download-dance (dirty but worky)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment