ASP 文件上传和文件下载代码
saveannounce_upload.asp 上传页
------------------------------------
------------------------------------
saveannouce_upfile.asp 保存文件到服务器
------------------------------------
<%
dim upload,file,formName,formPath
set upload=new upload_5xSoft ''建立上传对象
formPath=upload.form("filepath") ''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&;"/"
for each formName in upload.file ''列出所有上传了的文件
set file=upload.file(formName) ''生成一个文件对象
if file.filesize<100 then
response.write "
请先选择你要上传的文件 [ 重新上传 ]"
response.end
end if
if file.filesize>500*1000 then '设置上传文件大小为500K
response.write "
文件大小超过了限制 500K [ 重新上传 ]"
response.end
end if
if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath("updata\"&;file.FileName) ''保存文件
end if
set file=nothing
next
set upload=nothing
response.write "
文件上传成功 [ 继续上传 ]"
%>
------------------------------------
upload.inc 建立upload对象
------------------------------------