keha76

Force Download with PHP

Mar 23rd, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. // Force download of the file
  2. header( 'Content-Description: File Transfer' );
  3. header( 'Content-Type: application/octet-stream' );
  4. header( 'Content-Disposition: attachment; filename=' . basename( $file_path ) );
  5. header( 'Content-Transfer-Encoding: binary' );
  6. header( 'Expires: 0' );
  7. header( 'Cache-Control: must-revalidate' );
  8. header( 'Pragma: public' );
  9. header( 'Content-Length: ' . filesize( $file_path ) );
  10. readfile( $file_path );
Add Comment
Please, Sign In to add comment