DDR爱好者之家 Design By 杰米
但也许是随着asp的逐渐淡出web开发,官方仅提供了.net、php等版本的上传处理程序,对于asp开发者来说则需要自行处理服务器端的数据接收。

刚接触此组件时就被它功能强大与灵活方便吸引,由于当时项目采用asp开发,百度一番后发现并无好用的asp上传处理程序(现在有很多啦^^),看来只能自己研究开发啦,最初采用处理普通上传的方法来截取文件的数据,几经测试发现并不能有效接收组件传递过来的文件数据,无奈只能着手分析下它发送的数据形式,通过分析发现它发送的数据格式还是和普通上传存在一些区别的,无论是图片还是文件都是以octet-stream形式发送到服务器的,了解了数据格式,剩下的就是截取啦,下面把我的处理方法分享给需要的朋友,处理速度还算理想。
复制代码 代码如下:
<%
Class SWFUpload

Private formData, folderPath, streamGet
Private fileSize, chunkSize, bofCont, eofCont

REM CLASS-INITIALIZE

Private Sub Class_Initialize
Call InitVariant
Server.ScriptTimeOut = 1800
Set streamGet = Server.CreateObject("ADODB.Stream")

sAuthor = "51JS.COM-ZMM"
sVersion = "Upload Class 1.0"
End Sub

REM CLASS-INITIALIZE

Public Property Let SaveFolder(byVal sFolder)
If Right(sFolder, 1) = "/" Then
folderPath = sFolder
Else
folderPath = sFolder & "/"
End If
End Property

Public Property Get SaveFolder
SaveFolder = folderPath
End Property

Private Function InitVariant
chunkSize = 1024 * 128

folderPath = "/" : fileSize = 1024 * 10
bofCont = StrToByte("octet-stream" & vbCrlf & vbCrlf)
eofCont = StrToByte(vbCrlf & String(12, "-"))
End Function

Public Function GetUploadData
Dim curRead : curRead = 0
Dim dataLen : dataLen = Request.TotalBytes

streamGet.Type = 1 : streamGet.Open
Do While curRead < dataLen
Dim partLen : partLen = chunkSize
If partLen + curRead > dataLen Then partLen = dataLen - curRead
streamGet.Write Request.BinaryRead(partLen)
curRead = curRead + partLen
Loop
streamGet.Position = 0
formData = streamGet.Read(dataLen)

Call GetUploadFile
End Function

Public Function GetUploadFile
Dim begMark : begMark = StrToByte("filename=")
Dim begPath : begPath = InStrB(1, formData, begMark & ChrB(34)) + 10
Dim endPath : endPath = InStrB(begPath, formData, ChrB(34))
Dim cntPath : cntPath = MidB(formData, begPath, endPath - begPath)
Dim cntName : cntName = folderPath & GetClientName(cntPath)

Dim begFile : begFile = InStrB(1, formData, bofCont) + 15
Dim endFile : endFile = InStrB(begFile, formData, eofCont)

Call SaveUploadFile(cntName, begFile, endFile - begFile)
End Function

Public Function SaveUploadFile(byVal fName, byVal bCont, byVal sLen)
Dim filePath : filePath = Server.MapPath(fName)
If CreateFolder("|", GetParentFolder(filePath)) Then
streamGet.Position = bCont
Set streamPut = Server.CreateObject("ADODB.Stream")
streamPut.Type = 1 : streamPut.Mode = 3 : streamPut.Open
streamPut.Write streamGet.Read(sLen)
streamPut.SaveToFile filePath, 2
streamPut.Close : Set streamPut = Nothing
End If
End Function

Private Function IsNothing(byVal sVar)
IsNothing = IsNull(sVar) Or (sVar = Empty)
End Function

Private Function StrToByte(byVal sText)
For i = 1 To Len(sText)
StrToByte = StrToByte & ChrB(Asc(Mid(sText, i, 1)))
Next
End Function

Private Function ByteToStr(byVal sByte)
Dim streamTmp
Set streamTmp = Server.CreateObject("ADODB.Stream")
streamTmp.Type = 2
streamTmp.Mode = 3
streamTmp.Open
streamTmp.WriteText sByte
streamTmp.Position = 0
streamTmp.CharSet = "utf-8"
streamTmp.Position = 2
ByteToStr = streamTmp.ReadText
streamTmp.Close
Set streamTmp = Nothing
End Function

Private Function GetClientName(byVal bInfo)
Dim sInfo, regEx
sInfo = ByteToStr(bInfo)
If IsNothing(sInfo) Then
GetClientName = ""
Else
Set regEx = New RegExp
regEx.Pattern = "^.*\\([^\\]+)$"
regEx.Global = False
regEx.IgnoreCase = True
GetClientName = regEx.Replace(sInfo, "$1")
Set regEx = Nothing
End If
End Function

Private Function GetParentFolder(byVal sPath)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^(.*)\\[^\\]*$"
regEx.Global = True
regEx.IgnoreCase = True
GetParentFolder = regEx.Replace(sPath, "$1")
Set regEx = Nothing
End Function

Private Function CreateFolder(byVal sLine, byVal sPath)
Dim oFso
Set oFso = Server.CreateObject("Scripting.FileSystemObject")
If Not oFso.FolderExists(sPath) Then
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^(.*)\\([^\\]*)$"
regEx.Global = False
regEx.IgnoreCase = True
sLine = sLine & regEx.Replace(sPath, "$2") & "|"
sPath = regEx.Replace(sPath, "$1")
If CreateFolder(sLine, sPath) Then CreateFolder = True
Set regEx = Nothing
Else
If sLine = "|" Then
CreateFolder = True
Else
Dim sTemp : sTemp = Mid(sLine, 2, Len(sLine) - 2)
If InStrRev(sTemp, "|") = 0 Then
sLine = "|"
sPath = sPath & "\" & sTemp
Else
Dim Folder : Folder = Mid(sTemp, InStrRev(sTemp, "|") + 1)
sLine = "|" & Mid(sTemp, 1, InStrRev(sTemp, "|") - 1) & "|"
sPath = sPath & "\" & Folder
End If
oFso.CreateFolder sPath
If CreateFolder(sLine, sPath) Then CreateFolder = True
End if
End If
Set oFso = Nothing
End Function

REM CLASS-TERMINATE

Private Sub Class_Terminate
streamGet.Close
Set streamGet = Nothing
End Sub

End Class

REM 调用方法
Dim oUpload
Set oUpload = New SWFUpload
oUpload.SaveFolder = "存放路径"
oUpload.GetUploadData
Set oUpload = Nothing
%>
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。