Posted By

irishsk on 11/11/08


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jpsirois


Force Download of File


 / Published in: PHP
 

  1. header("Content-type: application/octet-stream");
  2.  
  3. // displays progress bar when downloading (credits to Felix ;-))
  4. header("Content-Length: " . filesize('myImage.jpg'));
  5.  
  6. // file name of download file
  7. header('Content-Disposition: attachment; filename="myImage.jpg"');
  8.  
  9. // reads the file on the server
  10. readfile('myImage.jpg');

Report this snippet  

You need to login to post a comment.