FileUpload valueProperty

Fileupload 对象参考手册Fileupload Object

Definition and Usage

The value property returns the file path and name selected by the <input type="file"> element.

In IE, Google Chrome, Opera, Firefox, and Safari browsers, the value property returns a fake path name of the selected file.

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

Syntax

fileuploadObject.value


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value property


Example

Example

Display the name of the selected file:

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

<form>
Choose a file to upload:
<input type="file" id="fname" size="50"/>
</form>
<button type="button" onclick="displayResult()">Show file path</button>

</body>
</html>

Try it Yourself »


Fileupload 对象参考手册Fileupload Object Other Extensions