Page 1 of 1

Image downlaoding Code

Posted: Tue Sep 29, 2009 7:50 am
by habib009pk
Dear Friends
I have an image with live live address of that image,
I want to download that image when i click on any link for that image, but the problem is that when i click on the link the image has been opened in another window.

kindly helps me for that when i clicked on any link then image will be download on my specific location

Waiting for your replies

Thanks

Re: Image downlaoding Code

Posted: Tue Sep 29, 2009 9:09 am
by s.dot
file_get_contents() to read the image and header() to set the mime type

Re: Image downlaoding Code

Posted: Wed Sep 30, 2009 2:43 am
by habib009pk
I got the result from this code Thanks

//Get the Query String
$file=$_SERVER["QUERY_STRING"];

//Get the values from Query String
$bidno=$_GET['bid'];
$picno=$_GET['npic'];
$auct_id=$_GET['auct_id'];

//Cut five Character of Query String
$file=substr($file, 5, 2000);
$filename=$auct_id."_".$bidno."_".$picno.".jpg";

//Display the Save Box
header("Content-Type: application/octet-stream;");
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment; filename='.$filename.'');
readfile($file);