快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

不用组件实现上载功能(1)

\\\'---- 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
%>
返回类别: 教程
上一教程: 十天学会ASP之第四天
下一教程: 如何用ASP代码实现虚拟主机

您可以阅读与"不用组件实现上载功能(1)"相关的教程:
· 不用组件实现上载功能(2)
· 使用W3SOCKETS组件实现域名查询功能
· WEB打印设置解决方案三(FileSystem组件实现WEB打印)
· 用ASPMAIL组件实现E_MAIL自动反馈
· WEB打印设置解决方案三(FILESYSTEM组件实现WEB打印)
    微笑服务 优质保证 索取样品