FileUpload acceptProperty
FileUpload Object
Definition and Usage
The accept property sets or returns a comma-separated list of content types.
Syntax
Set the accept property:
fileuploadObject.accept="content-type,content-type,..."
Return the accept property:
fileuploadObject.accept
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the accept property! However, only Firefox, Opera, and Chrome browsers return the file type.
Example
Example
Display the content types accepted by the <input type="file"> element:
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("fname").accept;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Select a file to upload:
<input type="file" id="fname" size="50" accept="video/*">
</form>
<button type="button" onclick="displayResult()">Show accepted file types</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("fname").accept;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Select a file to upload:
<input type="file" id="fname" size="50" accept="video/*">
</form>
<button type="button" onclick="displayResult()">Show accepted file types</button>
</body>
</html>
Try it Yourself »
FileUpload Object Other Extensions