SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Save as (different name)

    Hello!

    When someone uploads some image to my images/ folder, i store it with an rand() number, so it doesnt collide with already uploaded images with same name. The uploaded filename is, for eg: '199093 image01.jpg' .

    But when i choose to download it, it just saves like '199093 image01.jpg'. Is there a way to set the default name for downloading to 'image01.jpg'?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If the browser displays the image as "199093 image01.jpg" then it'll be downloaded with that name. As far as your server is concerned, the user and the browser are the same thing. If you want to offer a link like "download.php?image=199093 image01.jpg" then it is certainly possible to offer the image with a different name, but other than that, no, it isn't possible. To download with a different name, it has to run through a script.

  3. #3
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i can do that, yes. How should I search for the script?

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Serve the image with a Content-Disposition HTTP header, and you can use the filename attribute to suggest a new name.

    Code:
    Content-Disposition: attachment; filename=sunset.jpg
    What I don't understand is what the heck this thread is doing in the HTML and XHTML forum, since it doesn't have anything to do with either of those markup languages.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Addict Feudalism's Avatar
    Join Date
    Jun 2002
    Location
    Buenos Aires, Argentina
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry Autistic, I thought it may be solved via html. If any operator is reading, please change te thread to the correct forum.


Bookmarks

Posting Permissions

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