<%OPTION EXPLICIT%>
<!--#include FILE="../clsUp.asp"-->
<%
dim upfile,file,formPath,ServerPath,FSPath,formName,FileName,oFile,upfilecount,newfilename
upfilecount=0
set upfile=new clsUp ''建立上传对象
upfile.NoAllowExt="asp;exe;htm;html;aspx;cs;vb;js"
'设置上传类型的黑名单
upfile.GetData (10240000)
'取得上传数据,限制最大上传10M
%>
<html>
<head>
<title>文件上传</title>
<style>
BODY {
FONT-SIZE: 9pt; MARGIN: 0px; COLOR: #000000; FONT-FAMILY: "Arial"; TEXT-DECORATION: none;
background-color: #ffffff;
background-position : center top;
background-attachment : fixed ;
background-repeat : repeat-y;
}
TABLE {
FONT-SIZE: 9pt; LINE-HEIGHT: 16pt; FONT-FAMILY: "Arial"; TEXT-DECORATION: none
}
TH
{
color: #FFFFFF;
background-color: #482400;
font-size: 12px;
font-weight:bold;
}
TD {
FONT-SIZE: 9pt; COLOR: #000000; LINE-HEIGHT: 150%; FONT-FAMILY: "Arial"; TEXT-DECORATION: none
}
.TableBorder
{
width:97%;border: 1px #482400 solid; background-color: #ffffff;
}
TD.TdBg{background-color:#FFF5E1;}
.uline{MARGIN: 10px 0px; BORDER-BOTTOM: #807d76 1px dotted}
.redcode{color:red}
.title{font-weight:bold;}
input{border:solid 1px #482400;BACKGROUND-COLOR: #E7DDD8;COLOR: #000000;FONT-FAMILY: "Arial";font-size: 12px;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="0" topmargin="0">
<%
if upfile.isErr then
'如果出错
select case upfile.isErr
case 1
Response.Write "你没有上传数据呀!是不是搞错了!"
case 2
Response.Write "你上传的文件超出我们的限制,最大1M"
end select
else
%>
<%
FSPath=GetFilePath(Server.mappath("uploadphone.asp"),"\")'取得当前文件在服务器路径
FSPath=FSPath&"uploadfile\"
ServerPath=GetFilePath(Request.ServerVariables("HTTP_REFERER"),"/")'取得在网站上的位置
for each formName in upfile.file '列出所有上传了的文件
set oFile=upfile.file(formname)
FileName=upfile.form(formName)'取得文本域的值
if not FileName>"" then
FileName=oFile.filename'如果没有输入新的文件名,就用原来的文件名
'upfile.SaveToFile formname,FSPath&FileName
''保存文件 也可以使用AutoSave来保存,参数一样,但是会自动建立新的文件名
'upfile.autosave formname,FSPath&FileName
newFileName=upfile.autosave(formname,FSPath&FileName)
%>
<%
if upfile.iserr then
Response.Write upfile.errmessage
else
if request.QueryString("parm")<>"" then
'response.Write "<script language='javascript'>parent.telform."&request.QueryString("parm")&".value='"&serverpath&"uploadfile/"&newFileName&"';<'/script>"
response.Write("<script language='javascript'>top.document.telform.pic.value='"&newFileName&"';</script>")
end if
upfilecount=upfilecount+1
Response.Write "上传成功&nbsp;"
response.Write(""&serverpath&"uploadfile/"&newFileName)
end if
%>
<%
set oFile=nothing
next
%>
<%
end if
set upfile=nothing
'删除此对象
%>
<!-- [<a href="uploadfile.htm">返回</a>]
-->
</body>
</html>
<%
function GetFilePath(FullPath,str)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, str))
Else
GetFilePath = ""
End If
End function
%>
这是上传文件中的代码