-
您的位置:首页 → 技术开发 → ASP技巧 → 不用组件实现上载功能1
不用组件实现上载功能1
时间:2004/11/7 4:10:00来源:本站整理作者:蓝点我要评论(0)
-
'---- file name /upaoad.asp/
<%
Public Function BuildUploadRequest(strRequestBin)
Dim PosBeg, PosEnd, boundary, boundaryPos
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(13)))
boundary = MidB(strRequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,strRequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos = InstrB(strRequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
Dim Pos, Name
'Get an object name
Pos = InstrB(boundaryPos,strRequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,strRequestBin,getByteString("name="))
PosBeg = Pos + Len("name=") + 1
PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(34)))
Name = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
Dim PosFile, PosBound, ContentType, Value
'Test if object is of file type
PosFile = InstrB(BoundaryPos,strRequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,strRequestBin,boundary)
If PosFile <> 0 AND PosFile < PosBound Then
'Get FilePathName of the file
PosBeg = PosFile + Len("filename=") + 1
PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(34)))
FilePathName = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
'Add filename(with path) to dictionary object
UploadControl.Add "FilePathName", FilePathName
'Get Content-Type of the file
Pos = InstrB(PosEnd,strRequestBin,getByteString("Content-Type:"))
PosBeg = Pos + Len("Content-Type:") + 1
PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(13)))
ContentType = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
'Add content-type to dictionary object
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd + 4
PosEnd = InstrB(PosBeg,strRequestBin,boundary)-2
Value = MidB(strRequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,strRequestBin,getByteString(chr(13)))
PosBeg = Pos + 4
PosEnd = InstrB(PosBeg,strRequestBin,boundary)-2
Value = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
Set UploadRequest(Name) = UploadControl
'Loop to next object
BoundaryPos = InstrB(BoundaryPos+LenB(boundary),strRequestBin,boundary)
Loop
End Function
'String to byte string conversion
Public Function getByteString(strString)
Dim intCount
getByteString = ""
For intCount = 1 to Len(strString)
getByteString = getByteString & chrB(AscB(Mid(strString,intCount,1)))
Next
End Function
'Byte string to string conversion
Public Function getString(strString)
Dim intCount
getString = ""
For intCount = 1 to LenB(strString)
getString = getString & chr(AscB(MidB(strString,intCount,1)))
Next
End Function
%>
相关阅读
Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
-
热门文章
没有查询到任何记录。
最新文章
VB.NET 2005编写定时关
Jquery get/post下乱码解决方法 前台gbk gb如何使用数据绑定控件显示数据ASP脚本循环语句ASP怎么提速
人气排行
轻松解决"Server Application Error"和iis"一起学习DataGridView调整列宽用ASP随机生成文件名的函数Jquery get/post下乱码解决方法 前台gbk gbODBC Drivers错误80004005的解决办法返回UPDATE SQL语句所影响的行数的方法用Javascript隐藏超级链接的真实地址两个不同数据库表的分页显示解决方案
查看所有0条评论>>