Welcome Guest, Not a member yet? Register   Sign In
Is there any way to download a image when it is clicked?
#1

[eluser]chefnelone[/eluser]
hello

Just that. Any class, helper, plugin to to download a image when it is clicked?


I used to use this: (but since CI doesn't allow GET it doesn't work)
Code:
<?php
// Force download of image file specified in URL query string and which
// is in the same directory as this script:
if(!empty($_GET['img']))
{
   $filename = basename($_GET['img']); // don't accept other directories
   $size = @getimagesize($filename);
   $fp = @fopen($filename, "rb");
   if ($size && $fp)
   {
      header("Content-type: {$size['mime']}");
      header("Content-Length: " . filesize($filename));
      header("Content-Disposition: attachment; filename=$filename");
      header('Content-Transfer-Encoding: binary');
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      fpassthru($fp);
      exit;
   }
}
header("HTTP/1.0 404 Not Found");
?>


Thanks

and... Merry Christmas to everyone!


Messages In This Thread
Is there any way to download a image when it is clicked? - by El Forum - 12-24-2010, 04:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB