Latest web development tutorials

HTML DOM FileUpload accept property

Fileupload Object Reference Fileupload objects

Definition and Usage

accept property sets or returns a comma-separated content type.

grammar

Setting accept properties:

fileuploadObject.accept="content-type,content-type,..."

Returns accept attributes:

fileuploadObject.accept


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers are supported accept property! But only Firefox, Opera, and Chrome browser will return the file type.


Examples

Examples

Display <input type = "file"> element Acceptable Content Type:

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

<form id="form1">
选择一个文件上传:
<input type="file" id="fname" size="50" accept="video/*">
</form>

<button type="button" onclick="displayResult()">显示接收文件的类型</button>

</body>
</html>

try it"


Fileupload Object Reference Fileupload objects