This code should working, but I have no idea why it is not working at all.
HTML:
<p><input type="file" size="50"></p>
<p><input type="button" value="test" onclick="test()"></p>
JavaScript:
test = function() {
console.dir(document.querySelector('input[type="file"]').value);
var a = document.querySelector('input[type="file"]').vaule;
console.dir(a);
};
The first console.dir
can successfully display the selected file filename
whereas I store it in var a
is return undefined, whats happended?
fiddle: jsfiddle.net/eb5tuo7o
With the console log you're using
.value
but when you're storing it you've misspelled it as.vaule
.