Skip to content

Instantly share code, notes, and snippets.

@arturocr
Created May 9, 2012 19:36
Show Gist options
  • Select an option

  • Save arturocr/2648245 to your computer and use it in GitHub Desktop.

Select an option

Save arturocr/2648245 to your computer and use it in GitHub Desktop.

Revisions

  1. arturocr revised this gist May 9, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion forceDownload.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    @@ -9,4 +10,5 @@
    ob_clean();
    flush();
    readfile($file);
    exit;
    exit;
    ?>
  2. arturocr created this gist May 9, 2012.
    12 changes: 12 additions & 0 deletions forceDownload.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;