File Input accept Attribute
The HTML5 revolution provided us several simple but important attributes like download
, autofocus
, required
, novalidate
, and placeholder
. There's another one you may want to know about: accept
. The accept
attribute is useful for input[type=file]
elements. Let's have a look at it!
The HTML
I'll use Twitter's upload button to illustrate a good usage of the accept
attribute:
<input type="file" name="media_empty" accept="image/gif,image/jpeg,image/jpg,image/png,">
The accept
attribute gets a comma-separated list of mime types for files desired file types. In this case, Twitter is allowing the user to upload common image formats.
I get asked loads of questions every day but I'm always surprised that they're rarely questions about code or even tech -- many of the questions I get are more about non-dev stuff like what my office is like, what software I use, and oftentimes...
My trip to Mozilla Summit 2013 was incredible. I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out. MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...
News scroller have been around forever on the internet. Why? Because they're usually classy and effective. Over the next few weeks, we'll be taking a simple scroller and making it into a flexible, portable class. We have to crawl before we...
I've always been curious about the jQuery JavaScript library. jQuery has captured the hearts of web designers and developers everywhere and I've always wondered why. I've been told it's easy, which is probably why designers were so quick to adopt it NOT that designers...
The biggest problem about using this code is that the user can change it easily with firebug or others debugs.