The value
property returns the path or the file name
selected with the <input type="file"> element.
value |
Yes | Yes | Yes | Yes | Yes |
var v = fileuploadObject.value
A String type value representing the path or the name of the selected file.
The following code shows how to get the path or the name of the selected file.
<!DOCTYPE html>
<html>
<body>
Select a file to upload:<!-- w w w. j a v a2s . com-->
<input type="file" id="myFile" size="50">
<button type="button" onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myFile").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: