Posted By

indra on 08/26/10


Tagged

php


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

roli000


PHP: readfile - Manual


 / Published in: PHP
 

URL: http://php.net/manual/en/function.readfile.php

  1. <?php
  2. $file = 'monkey.gif';
  3.  
  4. if (file_exists($file)) {
  5. header('Content-Description: File Transfer');
  6. header('Content-Type: application/octet-stream');
  7. header('Content-Disposition: attachment; filename='.basename($file));
  8. header('Content-Transfer-Encoding: binary');
  9. header('Expires: 0');
  10. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  11. header('Pragma: public');
  12. header('Content-Length: ' . filesize($file));
  13. flush();
  14. readfile($file);
  15. }
  16. ?>

Report this snippet  

You need to login to post a comment.