Advertisement
Guest User

Untitled

a guest
Aug 17th, 2013
2,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2. if (isset($_GET['img'])) {$filename = $_GET['img'];}else{exit;}
  3. $allowed = array('gif','png','jpg');
  4. $ext = pathinfo($filename, PATHINFO_EXTENSION);
  5. if(!in_array($ext,$allowed)) {exit;}
  6. $stc = 31536000;
  7. $ts = gmdate("D, d M Y H:i:s", time() + $stc) . " GMT";
  8. header('Content-Type: application/octet-stream');
  9. header('Content-Disposition: attachment; filename=' . basename($filename));
  10. header('Content-Transfer-Encoding: binary');
  11. header("Expires: $ts");
  12. header("Cache-Control: max-age=$stc, public");
  13. header("Pragma: cache");
  14. ob_clean();
  15. flush();
  16. readfile($filename);
  17. exit;
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement