I'd like to create a button that when the user clicks it, the image it is associated with is downloaded to their local PC.
Essentially I have a gallery of images and each one has a download button attached to it.
I've got it to work by putting the relevant ASP code into a user control however I can't figure out how to call that user control from within the XLST where the gallery is located.
Any ideas? The code in the user control is very simple: it takes the URL of the image as a string parameter and downloads using Reponse.
I think setting the content-type to application/octet-stream will force the browser to download the image rather than render it, which is probably what you have in your usercontrol, Daniel? So in terms of actually facilitating this in Umbraco, there is more than one way to do this. My preferred way would be to set up a template which has the content-type code set in the template itself and takes the file name dynamically via a querystring, then either set up a specific document type to use for this or set an alternative template (altTemplate) on any other document.
Does this make sense? If not, let us know and someone will put together an example.
"Download" button (primarily images)
Hi all,
I'd like to create a button that when the user clicks it, the image it is associated with is downloaded to their local PC.
Essentially I have a gallery of images and each one has a download button attached to it.
I've got it to work by putting the relevant ASP code into a user control however I can't figure out how to call that user control from within the XLST where the gallery is located.
Any ideas? The code in the user control is very simple: it takes the URL of the image as a string parameter and downloads using Reponse.
Hi Daniel
I could be wrong, but I don't think you can force the user to download the image and save to their PC.
Providing a text link to the image enables the user to either :
1. Click on it and it will display in the browser, or
2. Right click and "save to PC".
So provide text beside the links to prompt the user to right click and save to their PC.
Cheers, Nigel
Hi Daniel (/Nigel),
I think setting the content-type to application/octet-stream will force the browser to download the image rather than render it, which is probably what you have in your usercontrol, Daniel? So in terms of actually facilitating this in Umbraco, there is more than one way to do this. My preferred way would be to set up a template which has the content-type code set in the template itself and takes the file name dynamically via a querystring, then either set up a specific document type to use for this or set an alternative template (altTemplate) on any other document.
Does this make sense? If not, let us know and someone will put together an example.
Nice work Dan... :-)
is working on a reply...