W3Schools.com

FileUpload value Property

Fileupload Object Reference Fileupload Object

Definition and Usage

The value property returns the path or the name of the file selected with the <input type="file"> element.

This property returns the name of the selected file with a fake path in IE, Google Chrome, and Opera, and the name of the selected file in Firefox and Safari.

Note: This property is read-only, because of security reasons.

Syntax

fileuploadObject.value


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Example

Example

Display the path or the name of the selected file:

<html>
<head>
<script type="text/javascript">
function displayResult()
{
var x=document.getElementById("fname").value;
alert(x);
}
</script>
</head>
<body>

<form>
Select a file to upload:
<input type="file" id="fname" size="50"/>
</form>

<button type="button" onclick="displayResult()">Display file path</button>

</body>
</html>

Try it yourself »


Fileupload Object Reference Fileupload Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE