Results 1 to 7 of 7
  1. #1
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default saving image to user machine

    I have a website in java which displays an image on its homepage. I need to provide an interface to the user which allows them to save this image on their desktop via an floppy icon placed next to it. Can you please let me know how to do this

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default

    I created a href pointing to that image, but when I click on that link, it opens the image in the browser, rather than prompting a dialog box to save it.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default

    Um, what does this have to do with Java?

    db

  5. #5
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default

    @ Darryl.Burke. I got it my problem solved through java only

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by nn12 View Post
    @ Darryl.Burke. I got it my problem solved through java only
    Can you show us how you going to solve this with Java? So that it's easy for us to comment.

  7. #7
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default

    Sure. My requirement was to display the image in the browser as well as to provide an save as button besides it. I read somewhere that response header Content-disposition allows you to do either of one the things mentioned above. Since in my case, I wanted both of the options, through my save as <a href> link I called another servlet which would set
    Java Code:
    response.setHeader("Content-disposition","attachment; filename=image.jpeg")
    and then wrote the image to the output stream
    Last edited by nn12; 03-10-2011 at 11:05 AM.

Similar Threads

  1. Replies: 0
    Last Post: 02-07-2011, 01:27 PM
  2. saving an image
    By shakeel in forum Java 2D
    Replies: 1
    Last Post: 12-25-2010, 10:08 AM
  3. Error in saving an Image????
    By LankanSniper in forum Java 2D
    Replies: 4
    Last Post: 11-07-2009, 04:48 AM
  4. Saving image to sever.
    By dudejonne in forum New To Java
    Replies: 5
    Last Post: 11-03-2009, 02:01 PM
  5. [SOLVED] Image drawing, saving
    By Goseph in forum Java 2D
    Replies: 2
    Last Post: 12-21-2008, 07:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •