下面 是上传文件的代码!
<%OPTION EXPLICIT%>
<%Server.ScriptTimeOut=5000%>
<!--#include file="config.asp"-->
<!--#include FILE="upload.inc"-->
<head>
<link href="iknow.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" leftmargin="0">
<%
if gx=1 then
if session("person")="" then
response.write"<script>alert('对不起,您未登录!');history.back();</script>"
end if
dim upload,file,formName,formPath,iCount,fname,ffname,zj
set upload=new upload_5xsoft ''建立上传对象
if upload.form("filepath")="" then ''得到上传目录
HtmEnd "请输入要上传至的目录!"
set upload=nothing
response.end
else
formPath=upload.form("filepath")
''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"
end if
iCount=0
for each formName in upload.objForm ''列出所有form数据
next
for each formName in upload.objFile ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.FileSize>5512000 then
response.write"<script>alert('对不起,文件超过5M!');history.back();</script>"
response.end
end if
if right(file.FileName,3)<>"rar" and right(file.FileName,3)<>"zip" and right(file.FileName,3)<>"txt" and right(file.FileName,3)<>"doc" and right(file.FileName,3)<>"xls" then
response.write"<script>alert('对不起,您上传的文件类型是不允许的!');history.back();</script>"
response.end
end if
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formPath&file.FileName) ''保存文件
fname=formPath&File.FileName
ffname=File.FileName
zj=file.FileSize
iCount=iCount+1
end if
set file=nothing
next
set upload=nothing ''删除此对象
Htmend iCount&""
sub HtmEnd(Msg)
set upload=nothing
response.write " 文件上传成功!<script>parent.document.ftiwen.fname.value='"&fname&"';</script><script>parent.document.ftiwen.zj.value='"&zj&"';</script><script>parent.document.ftiwen.ffname.value='"&ffname&"';</script>"
response.end
end sub
else
Response.Write ("<script>alert('对不起,共享资料功能未启用!');history.back();</script>")
Response.end
end if
%>