Tuesday, August 18, 2009

Dev : Upload File Mimetype

Storing an uploaded file to the database is not as easy as just storing string information. Storing the attachment as just a physical file and other info such as path, file name, mimetype and size is much easier.

But how come, all these while uploading file was never an issue, only until recently? Clients complaint that whenever they upload a ".docx" file, error will occur. After some findings on the log file, the error is actually the mimetype size that I have set for the database table was insufficient. Mine was varchar(50), but yet insufficient. So how long do you actually need? As for me, I have increased my original varchar(50) to varchar(100).

Why this long? After reading this, you will know why. This is the problem with MS. I don't even know why they need it to be so long. Here's a list of office extension with its mimetype from the Net.
Extension MIMEType
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.sldx application/vnd.openxmlformats-officedocument.presentationml.slide
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template

No comments: