Last active
August 29, 2015 14:00
-
-
Save raulghm/11382407 to your computer and use it in GitHub Desktop.
Detect browser file input support [http://stackoverflow.com/questions/12479897/detect-browser-file-input-support]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasFileUploadSupport(){ | |
var hasSupport = true; | |
try{ | |
var testFileInput = document.createElement('input'); | |
testFileInput.type = 'file'; | |
testFileInput.style.display = 'none'; | |
document.getElementsByTagName('body')[0].appendChild(testFileInput); | |
if(testFileInput.disabled){ | |
hasSupport = false; | |
} | |
} catch(ex){ | |
hasSupport = false; | |
} finally { | |
if(testFileInput){ | |
testFileInput.parentNode.removeChild(testFileInput); | |
} | |
} | |
return hasSupport; | |
} | |
alert(hasFileUploadSupport()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment