📄 saveupfile.asp
字号:
<!--#include file="conn.asp"--><!--#include file="inc/fun.asp"--><!--#include file="inc/upfile_class.asp"-->
<%
dim Cssstyleid,allthebbs
allthebbs=application(prefix&"allthebbs")
'application(prefix&"allthebbs")=""
Cssstyleid=request.cookies(prefix&"1")("styleid")
%>
<link rel="stylesheet" type="text/css" href="skin/<%=Cssstyleid%>/global.css">
<body leftmargin="0" topmargin="2">
<script>function putinstrHTML(str){
var documentedit;
var browserthis=parent.HtmlGetBrowser();
if (browserthis== 'IE') {
documentedit = parent.document.frames("EditForm").document;
} else {
documentedit = parent.document.getElementById('EditForm').contentDocument;
}
documentedit.body.innerHTML+=str;
}
function putinstrUBB(str){
var documentedit=parent.document.getElementById('CodeForm');
documentedit.value+=str;
}
</script>
<%
dim upfile,formPath,ServerPath,FSPath,formName,FileName,oFile,upfilecount,fileExtNoDot,fileExt
dim lguserid,uploadsize,uploadnum,uploadingnum,maxid,autotable,i,action,uploadtype,savepath,lgname,mymark
action=request("action")
if checknum(application(prefix&"canupload"))<>1 then response.end
lguserid=checknum(session(prefix&"lguserid"))
if isnull(lguserid) or lguserid="" then response.end
if action="headpic" then uploadtype="gif|jpg|bmp":savepath="images/headpic/upload"
if action="" then uploadtype=lcase(application(prefix&"uploadtype")):savepath="upload"
uploadsize=checknum(application(prefix&"uploadsize"))
uploadnum=checknum(application(prefix&"uploadnum"))
autotable=checknum(application(prefix&"autotable"))
uploadingnum=checknum(session(prefix&"uploadingnum"))
lgname=replace(request.cookies(prefix)("lgname"),"'","")
if uploadingnum>uploadnum-1 and action="" then
response.write "一次只能上传 <b>"&uploadingnum&"</b> 个文件!"
response.end
end if
mymark=conn.execute("select top 1 mark from [user] where userid="&lguserid&"")("mark")
if mymark<10 then
response.write"一次上传需要10点积分,你只有"&mymark&"点积分。"
response.end
end if
set upfile=new upfile_class ''建立上传对象
upfile.AllowExt=replace(uploadtype,"|",";")
upfile.GetData (uploadsize*1000) '取得上传数据,限制最大上传10M
%>
<%
if upfile.isErr then '如果出错
select case upfile.isErr
case 1
response.write "请先选择你要上传的文件 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
case 2
response.write "文件大小超过了限制 "&uploadsize&" Kb [ <a href=# onclick=history.go(-1)>重新上传</a> ]"
response.end
end select
else
FSPath=Server.mappath(savepath)&"\" '取得当前文件在服务器路径
for each formName in upfile.file '列出所有上传了的文件
set oFile=upfile.file(formName)
FileName=oFile.filename
fileExtNoDot=upfile.GetFileExt(FileName)
fileExt="."&fileExtNoDot
Filename=upfile.GetNewFileName&"-"&lguserid&fileExt
if action="headpic" then Filename=lguserid&fileExt
upfile.SaveToFile formName,FSPath&FileName ''保存文件 也可以使用AutoSave来保存,参数一样,但是会自动建立新的文件名
'论坛处理
if upfile.isErr=0 then
if action="" then
conn.execute("insert into upload(bbsid,filename,filetype,uploadtime,name,totable) values(0,'"&filename&"','"&fileExt&"',now()+"×et&"/24,'"&lgname&"',0)")
conn.execute("update [user] set mark=mark-10 where userid="&lguserid&"")
response.write "<script>var pstr='[upload="&fileExtNoDot&"]"&FileName&"[/upload]';putinstrHTML(pstr);putinstrUBB(pstr);</script>"
elseif action="headpic" then
response.write "<script>parent.form.mypic.value='"&savepath&"/"&FileName&"'</script>"
end if
end if
%>
<%
if upfile.iserr then
Response.Write upfile.errmessage
else
call UpEnd()
end if
set oFile=nothing
next
end if
set upfile=nothing '删除此对象
Sub UpEnd()
if action="" then
session(prefix&"uploadingnum")=uploadingnum+1
response.write "<b>"&session(prefix&"uploadingnum")&"</b> 文件上传成功,请copy下边的文件连接,以备后用!>><a href=upload.asp>继续上传</a>"
response.end
elseif action="headpic" then
response.write"上传成功,<a href=upload.asp?action=headpic>重新上传</a>。"
end if
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -