Computing.Net > Forums > Web Development > saving a jpeg locally

saving a jpeg locally

Reply to Message Icon

Original Message
Name: protos
Date: January 11, 2005 at 03:07:34 Pacific
Subject: saving a jpeg locally
OS: windows XP
CPU/Ram: pentium 4 /540MB
Comment:

Hi,
I want to replicate the behave the behaviour of
the "save as" option when you right click on an image in a webpage, using a button.
I have a button below the image, which when clicked brings up the "save-as" dialog box and allows the user to save the image locally.

Is this possible ?

Cheers
Colm


Report Offensive Message For Removal


Response Number 1
Name: Khalid
Date: January 11, 2005 at 14:29:10 Pacific
Reply: (edit)

This can be done with server-sided scripting. Normally, when you link an image, the image will appear in the window because the server sends some http-headers wich tell the browser what to do with the file.
You can manually alter these headers with a server-sided scripting language, like PHP or ASP.

In PHP you can use something like:

header("Content-Disposition: attachment; filename=image.jpg");
readfile("image.jpg");

More information can be found on php.net , or if you still dont know what to do, post back and someone will post a full example here.

Good luck!


Report Offensive Follow Up For Removal

Response Number 2
Name: protos
Date: January 11, 2005 at 18:17:53 Pacific
Reply: (edit)

Thanks for the reply :

What you're saying is that when an image link is clicked it looks at the header and if it sees that its an image it will display it instead of bringing up the save-as box ?

Can you give me an example ? I'm using coldfusion for the serverside stuff but anything will do ..........

Cheers
Colm


Report Offensive Follow Up For Removal

Response Number 3
Name: Khalid
Date: January 12, 2005 at 07:49:10 Pacific
Reply: (edit)

I have no experience with coldfusion, but googling comes up with some links you may find interesting.


By the way:

What I'm saying is that when an image link is clicked the server sends a normal header and if the server sees that its an image it will normally sends a header so the browser will 'know' what to do and displays it instead of bringing up the save-as box ? If the server sends some other headers, the browser knows 'what to do' i.e. show the save-as box.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: saving a jpeg locally

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge