Latest web development tutorials

HTML DOM Fileupload value property

Fileupload Object Reference Fileupload objects

Definition and Usage

value property returns <input type = "file"> file path and name of the selected elements.

In IE, Google Chrome, Opera, Firefox, Safari browser value property returns the selected file false path name.

Note: For security reasons, this property is read-only.

grammar

fileuploadObject.value


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute value


Examples

Examples

Display the selected file name:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("fname").value;
    alert(x);
}
</script>
</head>
<body>

<form>
选择一个文件上传:
<input type="file" id="fname" size="50"/>
</form>
<button type="button" onclick="displayResult()">显示文件路径</button>

</body>
</html>

try it"


Fileupload Object Reference Fileupload objects