Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing if a browser supports multiple file uploads?

Is there a way to test if a given browser supports the multiple attribute on file upload elements? Either a server-side or client-side implementation is sufficient.

I do realize I can test the user-agent against a list of known browsers that support the feature, but that seems like a rather frail implementation (ie. if IE 10 supports the feature when it finally launches, the I'll have to go edit back my code). I'd prefer to test support of the feature directly.

Thoughts?

like image 407
David Chouinard Avatar asked Sep 08 '26 08:09

David Chouinard


2 Answers

I'd recommend using "multiple" in document.createElement("input") for feature detection.

like image 195
duri Avatar answered Sep 10 '26 23:09

duri


Since this functionality is part of the HTML5 specification and is only just emerging in current implementations, you may not yet have a definitive and reliable way to do this. Want to know for sure? Then test it on as many browsers as possible. However, with that said, the code segment found at:

https://developer.mozilla.org/en/DOM/Input.multiple

does show that you should be able to determine this based on a simple test for the existence of the "multiple" attribute like is commonly used in many other elements.

like image 28
dmarietta Avatar answered Sep 10 '26 22:09

dmarietta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!