Question about IMG tags and file names

Discussion in 'ASP .Net' started by Rob, Oct 6, 2007.

  1. Rob

    Rob Guest

    Do browsers determine the type of a file by either looking at it's contents
    or it's file name when parsing an IMG tag? IE7 can be asked to display
    "Photo.tmp" which is actually a JPG and it displays it correct.

    Just worried that other browsers may to it a different way.

    The reason it's called TMP is that the file is coming out of a SQL IMAGE
    field and I don't have the original file name to hand.

    Cheers< Rob.
     
    Rob, Oct 6, 2007
    #1
    1. Advertising

  2. Are you saying you are saving the image in a file? This is unnecessary. The
    standard way of serving database images is making a special page
    GetImage.aspx that will get images from the database and stream them down
    top the client in the http response. The image url will look like
    "GetImage.aspx?id=xxx"/

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Rob" <rob_nicholson@nospam_unforgettable.com> wrote in message
    news:1dUNi.3630$...
    > Do browsers determine the type of a file by either looking at it's
    > contents or it's file name when parsing an IMG tag? IE7 can be asked to
    > display "Photo.tmp" which is actually a JPG and it displays it correct.
    >
    > Just worried that other browsers may to it a different way.
    >
    > The reason it's called TMP is that the file is coming out of a SQL IMAGE
    > field and I don't have the original file name to hand.
    >
    > Cheers< Rob.
    >
     
    Eliyahu Goldin, Oct 7, 2007
    #2
    1. Advertising

  3. Rob

    Rob Guest

    > Are you saying you are saving the image in a file? This is unnecessary.
    > The


    The image is saved in a database. Imagine a gallery of photos like on
    facebook. The application extracts the image from the database, writes it
    into a file and then generates IMG tags to point to the download files.

    It has to work this way - the generated pages are static, only updated
    periodically.

    So an IMG tag has to be used - the question is how to, with an IMG tag, does
    the browser work out what type of file it is? Does it a) look and the
    extension or b) look at the file header.

    And if (b) is that true for all browsers?

    Cheers, Rob.
     
    Rob, Oct 7, 2007
    #3
  4. > The image is saved in a database. Imagine a gallery of photos like on
    > facebook. The application extracts the image from the database, writes it
    > into a file and then generates IMG tags to point to the download files.
    >
    > It has to work this way - the generated pages are static, only updated
    > periodically.

    Still the standard solution looks better to me. There is absolutely no
    advantages in using files. You have to take care of deleting them, of file
    naming, of scalability.

    >
    > So an IMG tag has to be used - the question is how to, with an IMG tag,
    > does the browser work out what type of file it is? Does it a) look and the
    > extension or b) look at the file header.

    b)

    >
    > And if (b) is that true for all browsers?

    To be 100% sure, you need to investigate about every browser separately.
    For Mozilla this source
    http://developer.mozilla.org/en/docs/How_Mozilla_determines_MIME_Types says:
    ....for images loaded via <img src>, Mozilla's image library will do content
    sniffing (never extension sniffing) to find out the real type of the image.

    Look also in this: HTTP content-type and browser support
    http://www.byteflex.co.uk/http_content_type_and_browser_support.html


    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    >
    > Cheers, Rob.
    >
     
    Eliyahu Goldin, Oct 8, 2007
    #4
    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. news.austin.rr.com

    how to download img from html img tag

    news.austin.rr.com, Apr 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    517
    Steve C. Orr [MVP, MCSD]
    Apr 27, 2005
  2. Mark H. Wood
    Replies:
    2
    Views:
    5,478
    Andrew Thompson
    Jul 12, 2004
  3. Philipp Lenssen

    Problem: <img></img>

    Philipp Lenssen, Jun 27, 2005, in forum: XML
    Replies:
    15
    Views:
    773
    David Håsäther
    Jul 3, 2005
  4. Jopek
    Replies:
    7
    Views:
    407
    dorayme
    Apr 26, 2009
  5. Replies:
    7
    Views:
    185
    Tad McClellan
    Jun 22, 2006
Loading...

Share This Page