📄 doupload.asp
字号:
<!--#include file="inc/Upload_class.asp"-->
<!--#include file="mdb.asp"-->
<%
err.clear
Dim bdata,myupload,form,file,postion,size,f_name,msg
msg=""
bdata=request.binaryread(request.totalbytes)
'============================================
set myupload=new UpLoad '创建类实例
myupload.Path=server.mappath("upload") '设置上传路径(必须)
myupload.NameType="auto" '设置值为file代表用原文件名保存,auto代表用自动生成的日期字串保存,默认为auto
myupload.MaxSize=10*1024*1024 '设置最大上传限制,按字节计
myupload.Exe="rar|jpg|gif|bmp|chm|doc|pdf" '设置合法扩展名,以|分割,忽略大小写
myupload.GetData(bdata) '获取并保存数据
'============================================
msg=msg&"<font color=red><b>"&myupload.Description&"</b></font>"&vbcrlf '对于工作的描述
if myupload.Err<=0 then '未出现错误
for each file in myupload.files '可以用此循环保存文件
f_name="upload/"&file
postion=clng(split(myupload.files(file),"|")(0)) '数据流位置
size=clng(split(myupload.files(file),"|")(1)) '数据流大小,即文件大小
myupload.SaveToFile postion,size,file '调用类方法保存文件
msg=msg&"<li>文件<font color=green> "&file&" </font>保存完毕,大小<font color=green>"&myupload.getsize(size)&"</font>"&vbcrlf
next
sql="insert into Files([Title],[Content],[FileUrl],[AddTime]) values('"&myupload.forms("title")&"','"&myupload.forms("info")&"','"&f_name&"','"&now()&"')"
conn.execute sql
if err.number<>0 then
msg=msg&"<br><br><font color=red><b>保存到数据库错误:"&err.description&"</b></font>"
else
msg=msg&"<br><br><font color=red><b>保存到数据库完毕!</b></font>"
end if
end if
conn.close
set conn=nothing
set myupload=nothing '销毁类实例
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Refresh" content="2; URL=index.asp">
<title>文件上传...</title>
</head>
<body style="font-size:12px">
<pre>
=========================================================
类名: UpLoad
作者: Anlige
版本: AnUpload无组件上传类1.0
开发日期: 2008-6-12
网址: http://blog.ii-home.cn
Email: zhanghuiguoanlige@126.com
QQ: 417833272
备注:请查看例子学习其使用方法
=========================================================
</pre>
<%=msg%>
<br><br>
2秒后转向<a href="index.asp">文件列表</a>....
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -