What am I trying to do?
I am trying to validate a file after it has been selected using the input type="file" tag. One of the tests is to make sure that the filename is less than 200 characters long.
What have I done so far?
http://jsfiddle.net/joanferns00/ajeec780/4/ When I try to upload the following sample file, (file of filename length 230) 234_aaaaa6JHmFop6Va6JHmFRsdK7fxn1HtVkpl5UREy7cn4yC4hlHuW87qDp2fEg3YQlZCETrkBbLqIgtAqlklyahRIH0hCzSUO234_op6Va6JHmFRsdK7fxn1HtVkpl5UREy7cn4yC4hlHuW87qDp2fEg3YQlZCETrkBbLqIgtAqlklyahRIH0hCzSUOI3YQlZCETrkBbLqIgtAqlklkBbLqIgtAqlkl.txt
function getLength() {
//alert(.length);
var fullPath = document.getElementById("myfile").value;
if (fullPath) {
var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
var filename = fullPath.substring(startIndex);
if (filename.indexOf('\\') === 0 || filename.indexOf('/') === 0) {
filename = filename.substring(1);
}
alert(filename.length);
}
}
What do I expect?
I expect IE9 to alert the length of the text like it does in Chrome and FireFox
What is happening instead?
Firefox and chrome gives me a value of 230 however IE9 doesnt even allow me to upload the file.
Is there a way for IE9 to recognize this file and alert the filename length like Chrome and Firefox?