Jump to content

Image downlaoding Code


habib009pk

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/175926-image-downlaoding-code/
Share on other sites

I think you could do this by setting up a mod rewrite to redirect .jpg (or whatever image extension) to a php file that sets the header to "application/x-www-form-urlencoded" or something that would be downloaded.Then, draw the image using imagejpeg or something. The browser will want to download the file as whatever the basename in the url is, so you would want to dynamically generate that.

I got the result from this code.

 

 

//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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.