Skip to content

Instantly share code, notes, and snippets.

@phenix-factory
Created August 5, 2016 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phenix-factory/fa3d2d43b0d744a260fdc440fc9935a2 to your computer and use it in GitHub Desktop.
Save phenix-factory/fa3d2d43b0d744a260fdc440fc9935a2 to your computer and use it in GitHub Desktop.
PHP : envoyer un fichier au navigateur
<?php
$size = filesize($file);
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
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: '.$size);
ob_clean();
flush();
readfile($file);
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment