📄 upload.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Server.ScriptTimeOut=100000000%>
<%Response.ContentType = "text/vnd.wap.wml; charset=utf-8"%><?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<head>
<meta http-equiv="Cache-Control" content="must-revalidate" forua="true"/>
<meta http-equiv="Cache-Control" content="no-cache" forua="true"/>
<meta http-equiv="Cache-Control" content="max-age=0" forua="true"/>
<meta http-equiv="Expires" content="0" forua="true"/>
<meta http-equiv="Pragma" content="no-cache" forua="true"/>
</head>
<!--#INCLUDE VIRTUAL="/dwap/conn.inc"-->
<!--#include file=upload_5xsoft_xywap.inc-->
<%
Dim const_txl_HomeUrl,errstr,orderto,content
Dim intro,filename,maxphotoSize,upflag,newphotoid,photoSize,photoFormat
dim tid
tid=TRim(Request("tid"))
if glsb<>"" then
%>
<card id="index" title="文件上传"><p>
<%
Sub upload_5xsoft_upload
Dim upload,file,formName,FileExp,iCount,TotalSize
set upload=new upload_5xsoft
If not isobject(upload) Then
response.write "上传文件出错,服务器不支持该上传对象<br/>"
response.write "<anchor>返回上一页<prev/></anchor><br/>"
upflag=False
exit sub
End If
iCount=0
For each formName in upload.objFile
Set file=upload.file(formName)
If file.FileSize>0 Then
FileExp=lcase(Right(file.FileName,Len(file.FileName)-InstrRev(file.FileName,".")))
If not CheckExp(FileExp) Then
response.write "上传文件出错,当前设置不能上传该格式的文件!<br/>"&FileExp
response.write "<anchor>返回上一页<prev/></anchor><br/>"
upflag=False
exit sub
End IF
FileExp="."&FileExp
photoFormat=FileExp
TotalSize=file.FileSize/1024
photoSize=TotalSize
If TotalSize>maxphotoSize Then
response.write "上传文件出错,所传文件已经大于设定的允许值,当前所传文件大小"&TotalSize&"Kb!<br/>"
response.write "<anchor>返回上一页<prev/></anchor><br/>"
upflag=False
exit sub
End If
filename=GetRndFileName&FileExp
File.SaveAs Server.mappath(const_txl_HomeUrl&const_photoup_path&filename) ''保存文件
iCount=iCount+1
Else
response.write "上传文件出错,上传数据为空,请检查该文件是否存在!<br/>"
response.write "<anchor>返回上一页<prev/></anchor><br/>"
upflag=False
exit sub
End If
Set File=nothing
next
set upload=nothing ''删除此对象
upflag=True
End Sub
Sub SaveToDataBase
if oid=2 then
set rs_li=server.CreateObject("adodb.recordset")
sql_li="select * from lttz where tid="&tid&" and fid="&myid
rs_li.open sql_li,conn,1,3
if not (rs_li.bof and rs_li.eof) then
rs_li("upfile")="utf/"&filename
rs_li.update()
response.write "恭喜你,上传文件成功!<br/>"
else
Response.Write("没有该帖子!")
end if
Rs_li.close
set rs_li=nothing
else
set rs_li=server.CreateObject("adodb.recordset")
sql_li="select * from lttz where tid="&tid&" and fid="&myid
rs_li.open sql_li,conn,1,3
if not (rs_li.bof and rs_li.eof) then
rs_li("fjian")="upfile/"&filename
rs_li.update()
response.write "恭喜你,上传文件成功!<br/>"
else
Response.Write("没有该帖子!")
end if
Rs_li.close
set rs_li=nothing
end if
End Sub
Rem 文件扩展名检测
Function CheckExp(TheFileExp)
Dim defaultphotoFormat,i
TheFileExp=lcase(TheFileExp)
CheckExp=False
If TheFileExp="" Then
CheckExp=False
Exit Function
End If
If Instr(const_photoFormat,"/")>0 Then
defaultphotoFormat=Split(const_photoFormat,"/")
Else
defaultphotoFormat=const_photoFormat
End If
If IsArray(defaultphotoFormat) Then
For i=0 To Ubound(defaultphotoFormat)
If TheFileExp=defaultphotoFormat(i) Then
CheckExp=True
Exit For
End If
Next
Else
If TheFileExp=defaultphotoFormat Then
CheckExp=True
End If
End If
End Function
Function GetRndFileName()
Dim tmpstr
randomize
tmpstr=Int(1000*rnd)
'tmpstr=""&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&tmpstr&"_t125_com"
tmpstr=""&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&tmpstr
GetRndFileName=tmpstr
End Function%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -