Posted By

MrFjords on 02/15/11


Tagged

php download


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Image Download


 / Published in: PHP
 

  1. function forceImageDownload($image_path) {
  2.  
  3. //set filename
  4. $filename = basename($image_path);
  5.  
  6. //headers
  7. header("Content-Transfer-Encoding: binary");
  8. header("Content-Type: image/jpg");
  9. header("Content-Disposition: attachment; filename=$filename");
  10.  
  11. readfile($path_to_image);
  12. }

Report this snippet  

You need to login to post a comment.