Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel Abbitt 13 posts 33 karma points
    Aug 06, 2012 @ 11:39
    Daniel Abbitt
    0

    "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.

  • Nigel Wilson 945 posts 2077 karma points
    Aug 06, 2012 @ 22:02
    Nigel Wilson
    0

    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

  • Dan 1288 posts 3921 karma points c-trib
    Aug 06, 2012 @ 22:49
    Dan
    0

    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.

  • Nigel Wilson 945 posts 2077 karma points
    Aug 06, 2012 @ 22:55
    Nigel Wilson
    0

    Nice work Dan...  :-)

Please Sign in or register to post replies

Write your reply to:

Draft