Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Question about IMG tags and file names

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob - 06 Oct 2007 23:44 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 - 07 Oct 2007 09:41 GMT
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"/

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.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
[quoted text clipped - 6 lines]
>
> Cheers< Rob.
Rob - 07 Oct 2007 23:15 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 - 08 Oct 2007 09:49 GMT
> 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

Signature

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

> Cheers, Rob.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.