让上传变的简简单单
来源:岁月联盟
时间:2004-05-24
<html>
<script languge="javascript" type="text/javascript">
function oncleck()
{
filename=document.getElementById("file01").value
if (filename=="")
alert("输入要上传的文件")
else
{
var filetype=new String(filename);
var i;
i=filetype.length;
filetype=filetype.substring(i-4,i);
var theform ;
theform=document.getElementById("form01");
theform.action="savefile.asp?filetype="+filetype;
return true;
}
return false;
}
function checkfile()
{
if (parent.window.document.getElementById("filename").value!="")
{
alert("文件已经上传!")
return false;
}
}
</script>
<body topmargin="0" bgcolor="#EDF1F1" leftmargin="0">
<form id=form01 method=post enctype="multipart/form-data" onsubmit="return oncleck()">
<input type=file name=file01 size=20 id=file01 onclick='checkfile()'><input type=submit value=上传>
</form>
</body>
</html>
asp服务端代码如下:
<%
'获取文件后缀名
'-------------------------------------------
filetype=request("filetype")
%>
这样便获得文件后缀名,如果你会变通的话,还可以加以组合,获得更多文件信息,例如:文件名等,
注意:关键理解为什么可以
上一篇:ASP技巧
下一篇:MySQL数据库函数详解(2)