how to save picture not displayed ?

Discussion in 'HTML' started by Tuckbros, Dec 17, 2004.

  1. Tuckbros

    Tuckbros Guest

    Hi everybody,
    I am doing a small site with picture to save. My problem is to offer
    pictures to download, not to display. Can someone tell me how can I make
    the "save as" dialog to open, without using the right clic and "save
    target as".
    Thanks in advance
    Tuckbros, Dec 17, 2004
    #1
    1. Advertising

  2. Tuckbros

    Fat Sam Guest

    Tuckbros wrote:
    > Hi everybody,
    > I am doing a small site with picture to save. My problem is to offer
    > pictures to download, not to display. Can someone tell me how can I
    > make the "save as" dialog to open, without using the right clic and
    > "save target as".
    > Thanks in advance


    Wrap up the images in a zip file?
    Fat Sam, Dec 17, 2004
    #2
    1. Advertising

  3. Tuckbros

    Steve Pugh Guest

    On Fri, 17 Dec 2004 17:54:05 +0100, Tuckbros <> wrote:

    >I am doing a small site with picture to save. My problem is to offer
    >pictures to download, not to display. Can someone tell me how can I make
    >the "save as" dialog to open, without using the right clic and "save
    >target as".


    You could lie about the mime type.

    You could put the image in a zip file.

    You could offer the image in a format that browsers don't usually
    display (TIFF for example).

    You could do nothing and let users see the image before deciding
    whether they want to save it or not.

    Steve
    Steve Pugh, Dec 17, 2004
    #3
  4. Tuckbros

    Richard Guest

    Steve Pugh wrote:

    > On Fri, 17 Dec 2004 17:54:05 +0100, Tuckbros <> wrote:


    >>I am doing a small site with picture to save. My problem is to offer
    >>pictures to download, not to display. Can someone tell me how can I make
    >>the "save as" dialog to open, without using the right clic and "save
    >>target as".


    > You could lie about the mime type.


    > You could put the image in a zip file.


    > You could offer the image in a format that browsers don't usually
    > display (TIFF for example).


    > You could do nothing and let users see the image before deciding
    > whether they want to save it or not.


    > Steve


    But he wants to do it without right clicking any thing.
    I don't think it's possible.
    Richard, Dec 17, 2004
    #4
  5. Tuckbros

    Tuckbros Guest

    Tuckbros wrote:
    > Hi everybody,
    > I am doing a small site with picture to save. My problem is to offer
    > pictures to download, not to display. Can someone tell me how can I make
    > the "save as" dialog to open, without using the right clic and "save
    > target as".
    > Thanks in advance


    The images I plan to save are generated with a php script. An image with
    poor quality but light is sent to the brother while a better is
    generated as a jpg file and stored on the server. I made a link from the
    light picture to the heavier, but it displays the image. And I would
    like to save it instead of displaying.
    I looked if I can compress it in a file but it will load the server for
    quite nothing.
    Tuckbros, Dec 17, 2004
    #5
  6. Tuckbros

    Fat Sam Guest

    Tuckbros wrote:
    > Tuckbros wrote:
    >> Hi everybody,
    >> I am doing a small site with picture to save. My problem is to offer
    >> pictures to download, not to display. Can someone tell me how can I
    >> make the "save as" dialog to open, without using the right clic and
    >> "save target as".
    >> Thanks in advance

    >
    > The images I plan to save are generated with a php script. An image
    > with poor quality but light is sent to the brother while a better is
    > generated as a jpg file and stored on the server. I made a link from
    > the light picture to the heavier, but it displays the image. And I
    > would like to save it instead of displaying.
    > I looked if I can compress it in a file but it will load the server
    > for quite nothing.


    Can you post a link please?

    --
    Sam.
    www.fixaphoto.co.uk
    Fat Sam, Dec 17, 2004
    #6
  7. Tuckbros

    Tuckbros Guest

    Fat Sam wrote:
    > Tuckbros wrote:
    >
    >>Tuckbros wrote:
    >>
    >>>Hi everybody,
    >>>I am doing a small site with picture to save. My problem is to offer
    >>>pictures to download, not to display. Can someone tell me how can I
    >>>make the "save as" dialog to open, without using the right clic and
    >>>"save target as".
    >>>Thanks in advance

    >>
    >>The images I plan to save are generated with a php script. An image
    >> with poor quality but light is sent to the brother while a better is
    >>generated as a jpg file and stored on the server. I made a link from
    >>the light picture to the heavier, but it displays the image. And I
    >>would like to save it instead of displaying.
    >>I looked if I can compress it in a file but it will load the server
    >>for quite nothing.

    >
    >
    > Can you post a link please?
    >

    a link to what ?
    Tuckbros, Dec 17, 2004
    #7
  8. Tuckbros

    Fat Sam Guest

    Tuckbros wrote:
    > Fat Sam wrote:
    >> Tuckbros wrote:
    >>
    >>> Tuckbros wrote:
    >>>
    >>>> Hi everybody,
    >>>> I am doing a small site with picture to save. My problem is to
    >>>> offer pictures to download, not to display. Can someone tell me
    >>>> how can I make the "save as" dialog to open, without using the
    >>>> right clic and "save target as".
    >>>> Thanks in advance
    >>>
    >>> The images I plan to save are generated with a php script. An image
    >>> with poor quality but light is sent to the brother while a better
    >>> is generated as a jpg file and stored on the server. I made a link
    >>> from the light picture to the heavier, but it displays the image.
    >>> And I would like to save it instead of displaying.
    >>> I looked if I can compress it in a file but it will load the server
    >>> for quite nothing.

    >>
    >>
    >> Can you post a link please?
    >>

    > a link to what ?


    A link to the pages you have in place at the moment.....I'm not entirely
    clear what you mean by "poor quality but light" and also when you talk about
    sending an image to your brother......I thought if I could see the page it
    would make it easier to understand, and therefore find a solution......

    --
    Sam.
    www.fixaphoto.co.uk
    high quality photographic
    restorations and repairs
    Fat Sam, Dec 17, 2004
    #8
  9. Tuckbros

    Karl Core Guest

    "Tuckbros" <> wrote in message
    news:41c32a1d$0$22340$...
    > Tuckbros wrote:
    >> Hi everybody,
    >> I am doing a small site with picture to save. My problem is to offer
    >> pictures to download, not to display. Can someone tell me how can I make
    >> the "save as" dialog to open, without using the right clic and "save
    >> target as".
    >> Thanks in advance

    >
    > The images I plan to save are generated with a php script. An image with
    > poor quality but light is sent to the brother while a better is generated
    > as a jpg file and stored on the server. I made a link from the light
    > picture to the heavier, but it displays the image. And I would like to
    > save it instead of displaying.
    > I looked if I can compress it in a file but it will load the server for
    > quite nothing.


    Create a new PHP file and call it something like "downloadimage.php"

    Access it like so:
    http://www.example.com/downloadimage.php?img=foo.jpg

    Where 'foo.jpg' is the name of the image you want them to download

    <?php

    /* image name */
    $image_name=$_REQUEST['img'];

    /* content type here. you could do some sexy stuff to detect it, or you
    could hard-code it if you know that all of them are the same */
    header("Content-Type: image/jpeg");

    /* attachment disposition causes it to be treated like a download */
    header("Content-Disposition: attachment; filename=$image_name");
    readfile("../images/$image_name");
    ?>


    --
    -Karl Core
    Please Support "Project Boneyard":
    http://www.insurgence.net/info.aspx?action=band&item=boneyard
    Karl Core, Dec 17, 2004
    #9
  10. Tuckbros

    Tuckbros Guest

    Dear Karl Core,
    you are a master, thanks a lot.

    instead of linking to the picture I linked to the php file containing
    the following code :

    $image_name = "../../sessions/" . session_id() . "/Avatar.jpg" ;
    $save_name = "Avatar.jpg";
    /* attachment disposition causes it to be treated like a download */
    header("Content-Disposition: attachment; filename=$save_name");
    readfile("$image_name");

    where $save_name is the default name og the downloaded file and
    $image_name is the name of the image to saved.

    Karl Core wrote:
    > "Tuckbros" <> wrote in message
    > news:41c32a1d$0$22340$...
    >
    >>Tuckbros wrote:
    >>
    >>>Hi everybody,
    >>>I am doing a small site with picture to save. My problem is to offer
    >>>pictures to download, not to display. Can someone tell me how can I make
    >>>the "save as" dialog to open, without using the right clic and "save
    >>>target as".
    >>>Thanks in advance

    >>
    >>The images I plan to save are generated with a php script. An image with
    >>poor quality but light is sent to the brother while a better is generated
    >>as a jpg file and stored on the server. I made a link from the light
    >>picture to the heavier, but it displays the image. And I would like to
    >>save it instead of displaying.
    >>I looked if I can compress it in a file but it will load the server for
    >>quite nothing.

    >
    >
    > Create a new PHP file and call it something like "downloadimage.php"
    >
    > Access it like so:
    > http://www.example.com/downloadimage.php?img=foo.jpg
    >
    > Where 'foo.jpg' is the name of the image you want them to download
    >
    > <?php
    >
    > /* image name */
    > $image_name=$_REQUEST['img'];
    >
    > /* content type here. you could do some sexy stuff to detect it, or you
    > could hard-code it if you know that all of them are the same */
    > header("Content-Type: image/jpeg");
    >
    > /* attachment disposition causes it to be treated like a download */
    > header("Content-Disposition: attachment; filename=$image_name");
    > readfile("../images/$image_name");
    > ?>
    >
    >
    Tuckbros, Dec 17, 2004
    #10
  11. Tuckbros

    Steve Pugh Guest

    On Fri, 17 Dec 2004 12:23:11 -0600, "Richard" <Anonymous@127.001>
    wrote:
    > Steve Pugh wrote:
    >> On Fri, 17 Dec 2004 17:54:05 +0100, Tuckbros <> wrote:

    >
    >>>I am doing a small site with picture to save. My problem is to offer
    >>>pictures to download, not to display. Can someone tell me how can I make
    >>>the "save as" dialog to open, without using the right clic and "save
    >>>target as".

    >
    >> You could lie about the mime type.

    >
    >> You could put the image in a zip file.

    >
    >> You could offer the image in a format that browsers don't usually
    >> display (TIFF for example).

    >
    >> You could do nothing and let users see the image before deciding
    >> whether they want to save it or not.

    >
    >But he wants to do it without right clicking any thing.
    >I don't think it's possible.


    3 of the 4 options I gave would lead to that result. So yes it is
    possible, but there would be downsides that IMO outwiegh the
    perceieved benefit.

    Steve
    Steve Pugh, Dec 17, 2004
    #11
  12. "Richard" <Anonymous@127.001> wrote:

    > But he wants to do it without right clicking any thing.
    > I don't think it's possible.


    Oh, then you need to learn how to use your browser better.
    Or switch to an advanced browser like Lynx, which is excellent for
    downloading images (on well-designed sites).

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
    Jukka K. Korpela, Dec 19, 2004
    #12
  13. In article <Xns95C4755C3BFEDjkorpelacstutfi@193.229.0.31>,
    says...
    > Oh, then you need to learn how to use your browser better.
    > Or switch to an advanced browser like Lynx, which is excellent for
    > downloading images (on well-designed sites).


    So what you are really saying is that is sucks for downloading images on
    most of the web. (And before everyone jumps on me for trashing lynx, I
    am trashing most of the web, not lynx.)
    --
    -=*Tn*=-
    Travis Newbury, Dec 19, 2004
    #13
  14. Jukka K. Korpela, Dec 19, 2004
    #14
  15. In article <Xns95C4A94354E3Bjkorpelacstutfi@193.229.0.31>,
    says...
    > > So what you are really saying is that is sucks for downloading
    > > images on most of the web.

    > No, that's your idea and your words (and pseudo-sentence).


    And that differs from what you said how? (rhetorical question)
    --
    -=*Tn*=-
    Travis Newbury, Dec 19, 2004
    #15
  16. Tuckbros

    Guest

    Tuckbros <> wrote:
    > instead of linking to the picture I linked to the php file containing
    > the following code :
    >
    > $image_name = "../../sessions/" . session_id() . "/Avatar.jpg" ;
    > $save_name = "Avatar.jpg";
    > /* attachment disposition causes it to be treated like a download */
    > header("Content-Disposition: attachment; filename=$save_name");
    > readfile("$image_name");
    >
    > where $save_name is the default name og the downloaded file and
    > $image_name is the name of the image to saved.


    One thing I'm sure someone will mention (if they haven't already - I'm offline)

    Be very sure that you're getting your filename from a trusted source, Ie:

    $img = $_GET['IMG'];
    readfile("/dir/" . $img); /* This is not safe */

    Because some clown could come along and enter: IMG=../etc/passwd

    Looks like your base is covered pretty well, unless Mr. clown comes along
    and issues a bogus PHPSESSID. (or whatever your session variable is
    configured as) even then, it'd be hard to get around the Avatar.jpg portion,
    and I imagine their ability is limited by session variables which would likely
    disappear if they tampered with it.

    Using a regular expression or something to strip special characters or testing
    from a list to ensure IMG is actually what you'd intended are some common
    techniques.

    I just wanted to mention it in this thread in case someone is googling
    for the same problem. Looks like you took care of it, someone reading along
    might not be aware of it. (it is an easy thing to miss)

    Jamie
    --
    http://www.geniegate.com Custom web programming
    (rot13) User Management Solutions
    , Dec 30, 2004
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. boney
    Replies:
    1
    Views:
    551
  2. Wil
    Replies:
    8
    Views:
    350
    Beauregard T. Shagnasty
    Dec 16, 2006
  3. dorayme
    Replies:
    5
    Views:
    348
    dorayme
    Apr 28, 2008
  4. Shahar Golan
    Replies:
    5
    Views:
    278
    kaeli
    Oct 16, 2003
  5. Replies:
    8
    Views:
    1,220
    Mick White
    Apr 19, 2005
Loading...

Share This Page