I\'ve been setting up an import script for plain-text files in a web application.
My script is as follows:
function dataImport(files) {
confirm(\
if (file.type.match('text/plain')) {
// file type is text/plain
} else {
// file type is not text/plain
}
String.match is a RegEx, so if you would want to check, if the file is any type of text, you could do that:
if (file.type.match('text.*')) {
// file type starts with text
} else {
// file type does not start with text
}