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
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.