Forum Moderators: coopster

Message Too Old, No Replies

Save As button

         

sfast

2:47 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



Hi

I have a coupon image on a webpage and I need to have a download button on that webpage. Clicking on download button will save the image in the local directory.

I tried searching online for PHP code. I did not find anything. Can asomebody help me please.

d40sithui

3:35 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



letme get this straight,
1)you have an image, say "picture.jpg" thats displayed on the webpage.
2)what you want to do this save the image onto the same directory (on the server) when you click a button...or you want to save the image into your computer's harddrive?

GaryK

4:00 pm on Aug 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I read this as his wanting visitors to the website to click a button and have the coupon image on the page be saved to the visitor's HD.

If you're using an OS that supports the ADODB.Stream object you can do it fairly easily. There might be ways of doing it on other OSes but I'm not familiar with them.

Hope that helps. :)

[edited by: GaryK at 4:03 pm (utc) on Aug. 27, 2007]

sfast

4:48 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



Thanks Guys.

That is what I wanted to know. How a visitor can save coupon on his local drive.

Thanks for the directions.

d40sithui

6:07 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



i know of a way to use js to do this, but you have to use iframe, and its not supported under anything but IE5+ (at least thats the claim) assume that the filename is "peter.jpg"

<script>
var isReady = false;
function doSaveAs(){
if (img.document.execCommand){
if (isReady){img.document.execCommand("SaveAs", null, "peter.jpg");}
}else{
alert('This feature is only compatible with IE5+');
}
}
</script>

<iframe id='img' SRC="peter.jpg"></iframe>
<body onload="isReady=true">
<a href="javascript:doSaveAs()">
Click Here To Save This Image
</a>
</body>

there may be way to do this with setting the content-type w/ php, but im not too familar with that. maybe someone else has a beter idea for that

d40sithui

6:08 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



actualy u can shorten this line:
if (isReady){img.document.execCommand("SaveAs", null, "peter.jpg");}
...to
if (isReady){img.document.execCommand("SaveAs");}