How to make a link to a jpg picture download it?

Hello,
I'm getting a lot of new problems today, so here is my next question, how do i forca browser to save a jpg picture from a link instead of automatically opening it in the browser itself?

The best I could find is this link: http://codingforums.com/archive/index.php?t-34531.html, but It doesn't work. Any good suggestions how to do it?
GuanoFunAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Maverick_CoolCommented:
i had already answered a similar type in experts. first thing tell is this link a direct link  i mean in html u have the url path or not.
0
Maverick_CoolCommented:
please refer to my answere and this question in below URL of EE:
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23027377.html
0
GuanoFunAuthor Commented:
Yes, I have multiple logotips stored in JPG, GIF and other formats wich link directly to them. They are accually op the same server just in a /image/ directoy.

But as normaly browser acts when you click an image link - it opens in browser first. I want a person not needing to right-click and choose save target as, but with normal left-click to have act as it would have chosen save-targe-as already.

Basically, the useronly has to choose where to save the file if he wants to. I dont want to automatically download anything for him in any way, I just want to make things easier for the user ;)
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Maverick_CoolCommented:
the above url has all the answere's
0
GuanoFunAuthor Commented:
I read that, thanx, but i guess that is asp programming language which im totally not familiar with ... can you maybe axplain me in more detail how i can get that on my server and what to do with it?

I guess i know something just in php, css and javascript :(
0
Maverick_CoolCommented:
i am not good at php... sorry
0
GuanoFunAuthor Commented:
hmm... maybe you can explain what do with the asp script then?

Raised points to 250, since I see it won't be as easy as I though
0
Maverick_CoolCommented:
-------This   creates a file object and gets all its content as binary input
 Set oStream = Server.CreateObject("ADODB.Stream")
                oStream.Open
                   
                oStream.Type = 1
                oStream.LoadFromFile(path)
 -----------------------------------------------------------
                Response.Clear()

------------Setting the reponse buffer so what the whole is downloaded properly------------
                Response.Buffer = true
               
 -----telling the browser/response that content could be anything , the browser should interpet depending on file extension.In your case u can set Jepg see belloe commented code:
//response.ContentType ="image/jpeg"

                Response.ContentType = "whatever"
---------------------
adding the header for download telling rhe browser the  file should considered as attachment not as inline hence it show a save dialog, also i specify the the name as which it should be stored
                Response.AddHeader "content-disposition","attachment; filename=fname.ext"
--------------------------------------------------------------------------
                end select

---------------             reading file object data to response writer which will send the data to browser  
                Response.BinaryWrite oStream.Read
 
-----------clearing all objects/file objects used.....
                oStream.Close : Set oStream = Nothing
0
Michel PlungjanIT ExpertCommented:
<a href="saveImage.php?url=image1.jpg">Save image</a>

and in php:


<?php
$url = addslashes($_GET["url"]);
header('Content-type: content-type:octet-stream');
header('Content-Disposition: attachment; filename="'.$url.'"');
readfile('../images/'.$url);
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GuanoFunAuthor Commented:
WoW
thanks a lot, the best solution es really the easiest. works just perfect!

/cheer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.