For all of my questions I have received great answers. I have implemented the answers in code and they work. I now feel compelled to close the questions because I don't believe there are more or better answers out there.

Should you close your questions that you feel have been answered sufficiently? Would allowing more people to answer dilute the existing, good answers?

Return to FAQ index


Question: SQL: Saving MIME-Type or Extension?
Answer: If we are talking about file upload storage for example I will always store the following fields:


File - varbinary(MAX) 
FileName - nvarchar(255) (including file extension, for example "myfile.txt") 
FileType - nvarchar(255) (the MIME type)


The MIME type is important if it is a web based application and you want to allow download of the files at some point. Having the MIME type allow you to tell the browser how to best handle the file.

So the direct answer to your question is to save both the MIME type and the Extension. The reason being that you cannot ensure the correct file extension has been supplied so you need the MIME type to identify the file type. But you should store the extension with the filename so as you can provide a valid filename at download time.