动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 不用组件实现上载功能(英文NT)

作者:webwing 来源:chinaasp.com 
阅读 4102 人次 , 2001-2-28 

'---- 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
%>
  

 本文Tags组件  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:不用组件实现上载功能(英文NT)2
· 下一篇:在网页中实现OICQ里的头像选择的下拉框
· 取得服务器上用户组列表脚本之VBS版
· ASP漏洞集-MS IIS server/Frontpage Ext Server
· 复杂表单的动态生成与动态验证(转)
· ASP 3.0高级编程(四十五)
· ASP 3.0高级编程(一)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077