saveupload1.asp
来自「一个完全仿照阿里巴巴的网站管理系统 本软件没有版权问题」· ASP 代码 · 共 149 行
ASP
149 行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%dbdns="../../"%>
<!--#include file="../../inc/Config.asp"-->
<!--#include file="../cook.asp"-->
<%fla=split(session("adminflag"),",")
fla8=fla(8)
if fla8<>1 then
response.write "<script>alert('操作权限出错,您没有权限操作些功能');history.go(-1);</Script>"
Response.End
end if
''主程序开始部分
dim formsize,formdata,Msg
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
UploadSize=true
If formsize = 0 or Formsize > OKsizepic Then
UploadSize=false
Response.Write "<script>alert('你要上传的文件大小超出程序限制,请返回修改重试');history.go(-1);</Script>"
Response.End
End If
dim sinfo_Stream
set Sinfo_Stream = Server.CreateObject("adodb.stream")
Sinfo_Stream.Type = 1 ''2进制流
Sinfo_Stream.Mode = 3 ''读写模式
Sinfo_Stream.Open
Sinfo_Stream.Write formdata ''保存二进制内容到流对象
''分离数据变量
dim VbEnter
dim spStr,lenOfspStr,bpos
dim loopcnt,exitflag,ppoint,npoint
''保存数据变量
dim FldData,fldHeadStr,infldpos
dim databpos,datalen
dim FldInfo(15,1)
''fldInfo(0)表单头内容
''fldInfo(1)表单数据
VbEnter = chrb(13)&chrb(10)''读取第一个VbEnter位置
bpos = Instrb(formdata,VbEnter)
SpStr = midb(formdata,1,bpos+1) ''包含了一个0d0a
LenOfspStr = lenb(Spstr)
ppoint = LenOfspStr+1 ''位置指针,指向每一个表单域内容的开始位置
formdata = midb(formdata,ppoint)
loopcnt = 0 ''表单元素
do
bpos = instrb(formdata,spStr) ''分割位置
npoint = (ppoint+bpos+lenofspstr-1) ''指向下一表单开始位置
if bpos < 1 then
fldData = midb(formdata,1,instrb(formdata,leftb(spStr,lenOfspstr-2))-1)
bpos = lenb(fldData)+1
exitflag = true
else
FldData = leftb(formdata,bpos-1)
formdata = midb(formdata,bpos+LenOfspstr)
end if
infldpos = instrb(fldData,vbEnter&vbEnter)
fldHeadStr = bytes2bstr(midb(fldData,1,infldpos-1))
fldInfo(loopcnt,0) = fldHeadStr ''表单头
''Response.Write fldHeadStr&"<br>"
databpos = (ppoint+infldpos-1+4)
Sinfo_Stream.Position = databpos-1
datalen = (bpos-infldpos-6)
if datalen = 0 then
fldInfo(loopcnt,1) = ""
else
fldInfo(loopcnt,1) = Sinfo_Stream.Read(datalen)
end if
ppoint = npoint
loopcnt = loopcnt + 1
loop until exitflag = true
Sinfo_Stream.close
set Sinfo_Stream = Nothing
''以上程序数据处理过程
''写入数据库并处理文件上传开始
Sub SaveData()
coid=myrequest("coid")
tppic=myrequest("tppic")
templet=myrequest("templet")
others=myrequest("others")
files=replace(myrequest("files"),"/","")
flag=myrequest("flag")
if templet="" or others="" then
response.write "<script>alert('对不起,请填写完整内容!');history.go(-1);</Script>"
Response.End
end if
Msg = ""
filedata = myrequest("filedata")
filesize = lenb(filedata)
if filesize <> 0 then
filename = GetFileName("filedata")
file_ctype = GetContentType("filedata")
FileTypeName = GetFileTypeName(FileName)
If IsvalidFile(FileTypeName)=false Then
Response.Write "<script>alert('文件类型非法,不允许上传"&FileTypeName&"文件!');history.go(-1);</Script>"
Response.End
Exit Sub
End If
'==========================
path=server.mappath(Request.ServerVariables("SCRIPT_NAME"))
basepath=left(left(path,instrRev(path,"\")),len(left(path,instrRev(path,"\")))-14)&"co\"&files&"\img\"
dim Fstream
set FStream = Server.CreateObject("adodb.stream")
fstream.mode = 3
fstream.type = 1
fstream.open
fstream.position = 0
fstream.Write filedata
filename=tppic
nohack=split(filename,".")
tmpPath=basepath&nohack(0)&"."&nohack(ubound(nohack))
fstream.savetofile tmpPath,2
fstream.close
set fstream = nothing
'============================
else
filename=tppic
end if
'===================================================
dim basepath,sql
sql="select * from SMT_templet where SMT_id="& coid &""
set rs=server.createobject("ADODB.Recordset")
rs.open sql,myconn,1,3
rs("SMT_templet")=templet
rs("SMT_others")=others
rs("SMT_flag")=flag
rs("SMT_pic")=filename
rs.update
rs.close
set rs=nothing
myconn.close
set myconn = nothing
'===================================================
End Sub
SaveData
response.redirect "cp.asp"
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?