ie421.NET

面对技术,你别无选择,.NET世界是如此精彩,而我们要做的就是:Thinking More

博客园 首页 新随笔 联系 订阅 管理

<!--此特效来源来互联网,由 Yagebu.com 收集整理-->
<!--JS检测上传类型-->
<h4>JS检测上传类型</h4>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
extArray = new Array(".gif", ".jpg", ".png");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) form.submit();
else
alert("对不起,只能上传以下格式的文件:  " 
+ (extArray.join("  ")) + "\n请重新选择符合条件的文件"
+ "再上传.");
}
//  End -->
</script>


<script>
document.write(extArray.join("  "));
</script>
<p>

<form method=post name=upform action="/yourcgi.cgi" enctype="multipart/form-data">
<input type=file name=uploadfile>
<p>
<input type=button name="Submit" value="Submit" onclick="LimitAttach(this.form, this.form.uploadfile.value)">
</form>

posted on 2008-07-29 15:57  ie421  阅读(393)  评论(1编辑  收藏  举报