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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick prompt user to save file?

Status
Not open for further replies.

Zac5

Programmer
Joined
Jan 30, 2003
Messages
75
Location
US
Hi,

I need to display a button on a page which when clicked prompts the user to save a particular image on their machine. I know that you can do this by right clicking your mouse button on an image, however, in this case the image will not be displayed on the screen, instead a perl script will pass a file name. How can I do this using javascript and perl, I havent as yet found out how to prompt the user with a 'save' pop-up - does anyone have any ideas please?

Thanks,

Zac
 
AFAIK it can't be done because of mime types. The browser figures out what kind of file it is and takes appropriate action. While you could of course modify the action for the particular mime type, that would only be valid on your own machine.

--
Andy
 
You could probably just call it octet/stream or whatever the generic, unassociated, binary information mime type is. Then the script just outputs that mime type and then binary dumps the image to the browser, and it should be smart enough to save it (but I haven't tried).

----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
I don't believe so. A friend of mine wrote a sort of a thumbnailer and tried to do exactly what Zac wants. He even tried to trick it into thinking it was a different type of file, but it still figured out what type of file it actually was.

--
Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top