http://www.simplemachines.org/community/index.php?topic=545966.0
I feel some of this is relevant.
Yep. Definitely a bug ... had to fix that while importing Ruth's forum. finfo_file() seems to be the proper function.
Looks like to be able to store anything valid would be considered valid it needs to be 255. The spec allows 127 characters (recommends no more than 64) on each side of the /
I tried a search and found these:
https://www.sitepoint.com/web-foundations/mime-types-complete-list/
http://www.freeformatter.com/mime-types-list.html#mime-types-list
https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
https://www.iana.org/assignments/media-types/media-types.xhtml
In particular, that last one has a nice downloadable csv from which it's easy to get the length of each official MIME up to a couple of days ago. And it looks like the longest (both sides of the / combined) is 84 characters. The longest are the MS OpenXML documents with 70+ chars.
So, if we want to stay conservative, 100 would be more than enough, otherwise we can use the 255.
Thats fine as well ... better than what we have.
I was going by https://tools.ietf.org/html/rfc6838 section 4.2 of the Media Type Specifications which allows 127 + '/' + 127 = 256 but recommends as practical 64 + '/' + 64 = 129 .... either way the storage delta is pretty much moot given its a varchar and lenght() should simply imply whats reasonably expected ... I have no idea what reasonable is for this, but its not 20
Let's call 130 a deal? :P
Just go with 255. There is no reason not to. The size of the column doesn't change.
I think getting all of the IANA Media Types is something a mod might be better suited for. I'd say it should recognize all of the major: image types (png, bmp, jpg, gif), video types (mov, mp4, etc.), text types (txt, html, csv), MS Office document types (not the templates), and archive (zip, tar, gz, etc.) types by default.
Ohh... right, varchar takes only the space needed, I confused it with char I guess... or maybe something else entirely different. xD
The mime is recognized by php through finfo_open, the IANA db was just to have an idea of what are the existing mime to base the size of the field on a real-world example. ;)