-
-
Save stgoos/c1f0e48c7b667b107e606f89b66d4dff to your computer and use it in GitHub Desktop.
Handling file input
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
if (window.File && window.FileReader && window.FormData) { | |
var $inputField = $('#file'); | |
$inputField.on('change', function (e) { | |
var file = e.target.files[0]; | |
if (file) { | |
if (/^image\//i.test(file.type)) { | |
readFile(file); | |
} else { | |
alert('Not a valid image!'); | |
} | |
} | |
}); | |
} else { | |
alert("File upload is not supported!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment