Welcome Guest Search | Active Topics | Members | Log In | Register

Question about IMG tags and file names Options · View
Rob
Posted: Saturday, October 06, 2007 10:44:13 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 22:44:13
Date: Sat, 06 Oct 2007 22:44:13 GMT

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
Posted: Sunday, October 07, 2007 12:41:19 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 12:41:19
Date: Sun, 7 Oct 2007 10:41:19 +0200

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$WX3.900@newsfe5-win.ntli.net...
> 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
Posted: Sunday, October 07, 2007 10:15:41 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 22:15:41
Date: Sun, 07 Oct 2007 22:15:41 GMT

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


Eliyahu Goldin
Posted: Monday, October 08, 2007 12:49:44 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 08/10/2007 12:49:44
Date: Mon, 8 Oct 2007 10:49:44 +0200

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


Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.218 seconds.