Image downlaoding Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
habib009pk
Forum Commoner
Posts: 43
Joined: Sun Jul 05, 2009 11:28 pm

Image downlaoding Code

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Image downlaoding Code

Post by s.dot »

file_get_contents() to read the image and header() to set the mime type
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
habib009pk
Forum Commoner
Posts: 43
Joined: Sun Jul 05, 2009 11:28 pm

Re: Image downlaoding Code

Post 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);
Post Reply