Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saveing an Image

Status
Not open for further replies.

ptichka

Programmer
May 28, 2002
19
US
Hello everyone.

I have a number of images on my web page which are dynamically displayed. The user wants to be able to have a button that when slicked will prompted them to do a save.
I've tried using execCommand("SaveAs") but for some reason it seems to be inconsistent the was I have it now.

function SaveAsImage(obj)
{
newWindow = window.open(obj,"SaveImage","directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes, top=100000,left=100000, width=0, height=0");
newWindow.document.execCommand("SaveAs");
newWindow.close();
return false;
}


"obj" is a relative path of to the image (../../images/picture.jpg)

Some times the prompt has the name of the image and saves it properly. Other times it just says undefined.

If anyone have any suggestions for me that would be great.

Thanks.
 
I have used asp code to open a new window with just the saveas prompt - can you use asp for this?
 
simonchristieis,

I think I can use asp. But I don't really know asp. If you have the code that I can try that would be great.

Thanks.
 
like this:

Code:
<% 

Response.ContentType = "Application/gif"

fn = "myimage.gif"

FPath = "D:\images\"& fn

Response.AddHeader "content-disposition","attachment; filename=" & fn 
 
    Set adoStream = CreateObject("ADODB.Stream") 
    adoStream.Open() 
    adoStream.Type = 1 
    adoStream.LoadFromFile(FPath) 
    Response.BinaryWrite adoStream.Read() 
    adoStream.Close 
    Set adoStream = Nothing 
 
    Response.End 

%>

fn is the filename - you will need to pass this parameter into the page.

hth

simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top