前端 文件上传限制条件

<html>
<head>
<meta charset="utf-8">
<title>JS检查文件后缀</title>
</head>
<body>

<script type="text/javascript">
function selectFile(fnUpload) {
var filename = fnUpload.value;
var mime = filename.toLowerCase().substr(filename.lastIndexOf("."));
if(mime!=".jpg")
{
alert("请选择jpg格式的照片上传");
fnUpload.outerHTML=fnUpload.outerHTML;
}
}
</script>

<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" onchange="selectFile(this)" />
<br />
<input type="submit" name="submit" value="submit" />
</form>

</body>
</html>

前端 文件上传限制条件

上一篇:想看js某个原生函数的源码


下一篇:.Net 数据传值Cache