日期:2014-02-01 浏览次数:21025 次
<%
'Program:54powerman
'EMail & MSN:54powerman@163.com
'QQ:19486554
'初始化数据
Response.buffer=true
FormData = Request.BinaryRead(Request.TotalBytes)
bncrlf = ChrB(13)&ChrB(10)
Set sr=CreateObject("Adodb.Stream")
sr.Mode=3
sr.Type=1
sr.Open
sr.Write FormData
Init=sr
'常用函数
Function Str2B(Str)
For i = 1 To len(Str)
Str2B = Str2B&ChrB(Asc(Mid(Str,i,1)))
Next
End Function
Function B2Str(Str)
For i = 1 To LenB(Str)
ThisCharCode = AscB(MidB(Str,i,1))
If ThisCharCode < &H80 Then
B2Str = B2Str & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(Str,i+1,1))
B2Str = B2Str & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
End Function
Function MyRequest(FormName)
divider = leftb(FormData,inStrb(FormData,bncrlf)-1)
Cur = inStrb(FormData,Str2B("name=")&ChrB(34)&Str2B(FormName)&ChrB(34))
MyRequest=null
DataStart=inStrb(Cur,FormData,bncrlf&bncrlf)+4
DataEnd = inStrb(DataStart+1,FormData,divider)-DataStart
TempStr = Midb(FormData,Cur,DataStart)
If inStrb(TempStr,Str2B("filename=")) Then
MyRequest = Midb(FormData,DataStart,DataEnd)
else
MyRequest = B2Str(Midb(FormData,DataStart,DataEnd))
End If
End Function
Function GetFullName(FormName)
divider = leftb(FormData,inStrb(FormData,bncrlf)-1)
Cur = inStrb(FormData,Str2B("name=")&ChrB(34)&Str2B(FormName)&ChrB(34))
DataStart=inStrb(Cur,FormData,Str2B("filename="))+10
DataEnd = inStrb(DataStart+1,FormData,ChrB(34))-DataStart
TempStr = Midb(FormData,Cur,DataStart)
GetFullName = B2Str(Midb(FormData,DataStart,DataEnd))
End Function
Function GetFileName(FormName)
FullName=GetFullName(FormName)
GetFileName = Mid(FullName,InStrRev(FullName,"\")+1)
End Function
Function GetExpName(FormName)
GetExpName = Mid(GetFileName(FormName),InStrRev(GetFileName(FormName),".")+1)
End Function
Function SaveFile(FormName,FileName)
divider = leftb(FormData,inStrb(FormData,bncrlf)-1)
Cur = inStrb(FormData,Str2B("name=")&ChrB(34)&Str2B(FormName)&ChrB(34))
SaveFile=false
DataStart=inStrb(Cur,FormData,bncrlf&bncrlf)+4
DataEnd = inStrb(DataStart+1,FormData,divider)-DataStart
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
sr.Position=DataStart-1
sr.CopyTo dr,DataEnd
dr.SaveToFile FileName,2
sr.Close
set sr=nothing
dr.Close
set dr=nothing
SaveFile=true
End Function
Function FileSize(FormName)
divider = leftb(FormData,inStrb(FormData,bncrlf)-1)
Cur = inStrb(FormData,Str2B("name=")&ChrB(34)&Str2B(FormName)&ChrB(34))
FileSize=0
DataStart=inStrb(Cur,FormData,bncrlf&bncrlf)+4
FileSize = inStrb(DataStart+1,FormData,divider)-DataStart-2
End Function
%>