风声无组件上传类

博客涉及EXT和.net相关信息技术内容,但具体信息缺失。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

程序代码:
<%
'----------------------------------------------------------
'*****************风声无组件上传类2.0*****************
'作者:风声
'网站: http://www.17560.net http://www.54nb.com
'邮件:Rumor@17560.net
'版权:版权全体,源代码公开,各种用途均可免费使用
'**********************************************************
'----------------------------------------------------------
ClassUpLoadClass

Privatep_MaxSize,p_FileType,p_SavePath,p_AutoSave,p_Error
PrivateobjForm,binForm,binItem,strDate,lngTime
PublicFormItem,FileItem

PublicPropertyGetVersion
Version="RumorUpLoadClassVersion2.0"
EndProperty

PublicPropertyGetError
Error=p_Error
EndProperty

PublicPropertyGetMaxSize
MaxSize=p_MaxSize
EndProperty
PublicPropertyLetMaxSize(lngSize)
ifisNumeric(lngSize)then
p_MaxSize=clng(lngSize)
endif
EndProperty

PublicPropertyGetFileType
FileType=p_FileType
EndProperty
PublicPropertyLetFileType(strType)
p_FileType=strType
EndProperty

PublicPropertyGetSavePath
SavePath=p_SavePath
EndProperty
PublicPropertyLetSavePath(strPath)
p_SavePath=replace(strPath,chr(0),"")
EndProperty

PublicPropertyGetAutoSave
AutoSave=p_AutoSave
EndProperty
PublicPropertyLetAutoSave(byValFlag)
selectcaseFlag
case0:
case1:
case2:
casefalse:Flag=2
caseelse:Flag=0
endselect
p_AutoSave=Flag
EndProperty

PrivateSubClass_Initialize
p_Error=-1
p_MaxSize=153600
p_FileType="jpg/gif"
p_SavePath=""
p_AutoSave=0
strDate=replace(cstr(Date()),"-","")
lngTime=clng(timer()*1000)
SetbinForm=Server.CreateObject("ADODB.Stream")
SetbinItem=Server.CreateObject("ADODB.Stream")
SetobjForm=Server.CreateObject("Scripting.Dictionary")
objForm.CompareMode=1
EndSub

PrivateSubClass_Terminate
objForm.RemoveAll
SetobjForm=nothing
SetbinItem=nothing
binForm.Close()
SetbinForm=nothing
EndSub

PublicSubOpen()
ifp_Error=-1then
p_Error=0
else
ExitSub
endif
DimlngRequestSize,binRequestData,strFormItem,strFileItem
ConststrSplit="'"">"
lngRequestSize=Request.TotalBytes
iflngRequestSize<1then
p_Error=4
ExitSub
endif
binRequestData=Request.BinaryRead(lngRequestSize)
binForm.Type=1
binForm.Open
binForm.WritebinRequestData

DimbCrLf,strSeparator,intSeparator
bCrLf=ChrB(13)&ChrB(10)

intSeparator=InstrB(1,binRequestData,bCrLf)-1
strSeparator=LeftB(binRequestData,intSeparator)

Dimp_start,p_end,strItem,strInam,intTemp,strTemp
DimstrFtyp,strFnam,strFext,lngFsiz
p_start=intSeparator+2
Do
p_end=InStrB(p_start,binRequestData,bCrLf&bCrLf)+3
binItem.Type=1
binItem.Open
binForm.Position=p_start
binForm.CopyTobinItem,p_end-p_start
binItem.Position=0
binItem.Type=2
binItem.Charset="gb2312"
strItem=binItem.ReadText
binItem.Close()

p_start=p_end
p_end=InStrB(p_start,binRequestData,strSeparator)-1
binItem.Type=1
binItem.Open
binForm.Position=p_start
lngFsiz=p_end-p_start-2
binForm.CopyTobinItem,lngFsiz

intTemp=Instr(39,strItem,"""")
strInam=Mid(strItem,39,intTemp-39)

ifInstr(intTemp,strItem,"filename=""")<>0then
ifnotobjForm.Exists(strInam&"_From")then
strFileItem=strFileItem&strSplit&strInam
ifbinItem.Size<>0then
intTemp=intTemp+13
strFtyp=Mid(strItem,Instr(intTemp,strItem,"Content-Type:")+14)
strTemp=Mid(strItem,intTemp,Instr(intTemp,strItem,"""")-intTemp)
intTemp=InstrRev(strTemp,"\")
strFnam=Mid(strTemp,intTemp+1)
objForm.AddstrInam&"_Type",strFtyp
objForm.AddstrInam&"_Name",strFnam
objForm.AddstrInam&"_Path",Left(strTemp,intTemp)
objForm.AddstrInam&"_Size",lngFsiz
ifInstr(intTemp,strTemp,".")<>0then
strFext=Mid(strTemp,InstrRev(strTemp,".")+1)
else
strFext=""
endif
ifleft(strFtyp,6)="image/"then
binItem.Position=0
binItem.Type=1
strTemp=binItem.read(10)
ifstrcomp(strTemp,chrb(255)&chrb(216)&chrb(255)&chrb(224)&chrb(0)&chrb(16)&chrb(74)&chrb(70)&chrb(73)&chrb(70),0)=0then
ifLcase(strFext)<>"jpg"thenstrFext="jpg"
binItem.Position=3
dowhilenotbinItem.EOS
do
intTemp=ascb(binItem.Read(1))
loopwhileintTemp=255andnotbinItem.EOS
ifintTemp<192orintTemp>195then
binItem.read(Bin2Val(binItem.Read(2))-2)
else
Exitdo
endif
do
intTemp=ascb(binItem.Read(1))
loopwhileintTemp<255andnotbinItem.EOS
loop
binItem.Read(3)
objForm.AddstrInam&"_Height",Bin2Val(binItem.Read(2))
objForm.AddstrInam&"_Width",Bin2Val(binItem.Read(2))
elseifstrcomp(leftB(strTemp,8),chrb(137)&chrb(80)&chrb(78)&chrb(71)&chrb(13)&chrb(10)&chrb(26)&chrb(10),0)=0then
ifLcase(strFext)<>"png"thenstrFext="png"
binItem.Position=18
objForm.AddstrInam&"_Width",Bin2Val(binItem.Read(2))
binItem.Read(2)
objForm.AddstrInam&"_Height",Bin2Val(binItem.Read(2))
elseifstrcomp(leftB(strTemp,6),chrb(71)&chrb(73)&chrb(70)&chrb(56)&chrb(57)&chrb(97),0)=0orstrcomp(leftB(strTemp,6),chrb(71)&chrb(73)&chrb(70)&chrb(56)&chrb(55)&chrb(97),0)=0then
ifLcase(strFext)<>"gif"thenstrFext="gif"
binItem.Position=6
objForm.AddstrInam&"_Width",BinVal2(binItem.Read(2))
objForm.AddstrInam&"_Height",BinVal2(binItem.Read(2))
elseifstrcomp(leftB(strTemp,2),chrb(66)&chrb(77),0)=0then
ifLcase(strFext)<>"bmp"thenstrFext="bmp"
binItem.Position=18
objForm.AddstrInam&"_Width",BinVal2(binItem.Read(4))
objForm.AddstrInam&"_Height",BinVal2(binItem.Read(4))
endif
endif
objForm.AddstrInam&"_Ext",strFext
objForm.AddstrInam&"_From",p_start
intTemp=GetFerr(lngFsiz,strFext)
ifp_AutoSave<>2then
objForm.AddstrInam&"_Err",intTemp
ifintTemp=0then
ifp_AutoSave=0then
strFnam=GetTimeStr()
ifstrFext<>""thenstrFnam=strFnam&"."&strFext
endif
binItem.SaveToFileServer.MapPath(p_SavePath&strFnam),2
objForm.AddstrInam,strFnam
endif
endif
else
objForm.AddstrInam&"_Err",-1
endif
endif
else
binItem.Position=0
binItem.Type=2
binItem.Charset="gb2312"
strTemp=binItem.ReadText
ifobjForm.Exists(strInam)then
objForm(strInam)=objForm(strInam)&","&strTemp
else
strFormItem=strFormItem&strSplit&strInam
objForm.AddstrInam,strTemp
endif
endif

binItem.Close()
p_start=p_end+intSeparator+2
loopUntilp_start+3>lngRequestSize
FormItem=split(strFormItem,strSplit)
FileItem=split(strFileItem,strSplit)
EndSub

PrivateFunctionGetTimeStr()
lngTime=lngTime+1
GetTimeStr=strDate&lngTime
EndFunction

PrivateFunctionGetFerr(lngFsiz,strFext)
dimintFerr
intFerr=0
iflngFsiz>p_MaxSizeandp_MaxSize>0then
ifp_Error=0orp_Error=2thenp_Error=p_Error+1
intFerr=intFerr+1
endif
ifInstr(1,LCase("/"&p_FileType&"/"),LCase("/"&strFext&"/"))=0andp_FileType<>""then
ifp_Error<2thenp_Error=p_Error+2
intFerr=intFerr+2
endif
GetFerr=intFerr
EndFunction

PublicFunctionSave(Item,strFnam)
Save=false
ifobjForm.Exists(Item&"_From")then
dimintFerr,strFext
strFext=objForm(Item&"_Ext")
intFerr=GetFerr(objForm(Item&"_Size"),strFext)
ifobjForm.Exists(Item&"_Err")then
ifintFerr=0then
objForm(Item&"_Err")=0
endif
else
objForm.AddItem&"_Err",intFerr
endif
ifintFerr<>0thenExitFunction
ifVarType(strFnam)=2then
selectcasestrFnam
case0:strFnam=GetTimeStr()
ifstrFext<>""thenstrFnam=strFnam&"."&strFext
case1:strFnam=objForm(Item&"_Name")
endselect
endif
binItem.Type=1
binItem.Open
binForm.Position=objForm(Item&"_From")
binForm.CopyTobinItem,objForm(Item&"_Size")
binItem.SaveToFileServer.MapPath(p_SavePath&strFnam),2
binItem.Close()
ifobjForm.Exists(Item)then
objForm(Item)=strFnam
else
objForm.AddItem,strFnam
endif
Save=true
endif
EndFunction

PublicFunctionGetData(Item)
GetData=""
ifobjForm.Exists(Item&"_From")then
ifGetFerr(objForm(Item&"_Size"),objForm(Item&"_Ext"))<>0thenExitFunction
binForm.Position=objForm(Item&"_From")
GetData=binFormStream.Read(objForm(Item&"_Size"))
endif
EndFunction

PublicFunctionForm(Item)
ifobjForm.Exists(Item)then
Form=objForm(Item)
else
Form=""
endif
EndFunction

PrivateFunctionBinVal2(bin)
dimlngValue,i
lngValue=0
fori=lenb(bin)to1step-1
lngValue=lngValue*256+ascb(midb(bin,i,1))
next
BinVal2=lngValue
EndFunction

PrivateFunctionBin2Val(bin)
dimlngValue,i
lngValue=0
fori=1tolenb(bin)
lngValue=lngValue*256+ascb(midb(bin,i,1))
next
Bin2Val=lngValue
EndFunction

EndClass
%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值