FileUpload nameProperty

Fileupload 对象参考手册FileUpload Object

Definition and Usage

The name property sets or returns the value of the name attribute of the FileUpload object.

The name attribute is used to send data to the server after form submission, or to reference form data in JavaScript.

Note:After form submission, only the name attribute of form elements will transmit data values.

Syntax

Set the name property:

fileuploadObject.name="name"

Return the name property:

fileuploadObject.name


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the name property.


Example

Example

Display the value of the name attribute of the input element:

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

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

</body>
</html>

Try it Yourself »


Fileupload 对象参考手册FileUpload Object Other Extensions