2006-2-28 作者: 来源: 点击:1331
<%
Response.write "<title>上传文件至当前文件夹</title>"
Response.Write "<body bgcolor=""#D6D3CE"" leftmargin=""0"" topmargin=""0"" title = "" 请您遵守国家相关法律法规上传文件。上传前请杀毒,否则系统将会自动删除此文件!"">"
’**Start Encode**
Action=Request("A")
If Action="UL" Then
DoUpload Request.Cookies("DAZHOU.NET")("nowpath") & "\"
’CheckDiskSpace
’ Response.redirect "fileman.asp"
Else
ShowUploadForm
End If
Set fso=Nothing
’========================
SUB ShowUploadForm
’========================
Response.write "<Dir><form enctype=multipart/form-data name=fmupload method=Post action=Upload.asp?A=UL><br>"
If Request("n")<>"" AND IsNumeric(Request("n")) Then Session("NumUploadFields")=CInt(Request("n"))
For i=1 to 5
Response.Write "<INPUT type=file name=file"& i & " size=35><br>"
Next
Response.Write "<br><center><INPUT type=submit value=""开始上传""> <INPUT type=’button’ value= ’取消上传’ onclick=’window.close()’> "
Response.Write "</form>"
End SUB
’========================
SUB DoUpload(Dir)
’========================
’If NOT Application("Debugging") Then On Error resume next
StartTime=Now
RequestBin=Request.BinaryRead(Request.TotalBytes)
Set UploadRequest=CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin‚ UploadRequest
keys=UploadRequest.Keys
For i=0 to UploadRequest.Count - 1
curKey=keys(i)
fName=UploadRequest.Item(curKey).Item("FileName")
If fso.FileExists(Dir & fName) Then fso.deletefile Dir & fName
If fName<>"" AND NOT fso.FileExists(Dir & fName) Then
value=UploadRequest.Item(curKey).Item("Value")
valueBeg=UploadRequest.Item(curKey).Item("ValueBeg")
valueLen=UploadRequest.Item(curKey).Item("ValueLen")
TotalULSize=TotalULSize + valueLen
Set strm1=Server.CreateObject("ADODB.Stream")
Set strm2=Server.CreateObject("ADODB.Stream")
strm1.Open
strm1.Type=1 ’Binary
strm2.Open
strm2.Type=1 ’Binary
strm1.Write RequestBin
strm1.Position=ValueBeg
strm1.CopyTo strm2‚ValueLen
strm2.SaveToFile Dir & fName‚2
Set strm1=Nothing
Set strm2=Nothing
End If
Next
If Now>StartTime Then Response.Write("<br><br><br><br><center>上传成功!<br>速度: " & Round(TotalULSize/1024/DateDiff("s"‚StartTime‚Now)) &" 千字节/秒" )
Set UploadRequest=Nothing
End SUB
’========================
Sub BuildUploadRequest(RequestBin‚ UploadRequest)
’========================
’Get the boundary
PosBeg=1
PosEnd=InstrB(PosBeg‚RequestBin‚getByteString(chr(13)))
boundary=MidB(RequestBin‚PosBeg‚PosEnd-PosBeg)
boundaryPos=InstrB(1‚RequestBin‚boundary)
’Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin‚boundary & getByteString("--")))
’Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl=CreateObject("Scripting.Dictionary")
’Get an object name
Pos=InstrB(BoundaryPos‚RequestBin‚getByteString("Content-Disposition"))
Pos=InstrB(Pos‚RequestBin‚getByteString("name="))
PosBeg=Pos+6
PosEnd=InstrB(PosBeg‚RequestBin‚getByteString(chr(34)))
Name=getString(MidB(RequestBin‚PosBeg‚PosEnd-PosBeg))
PosFile=InstrB(BoundaryPos‚RequestBin‚getByteString("filename="))
PosBound=InstrB(PosEnd‚RequestBin‚boundary)
’Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
’Get Filename‚ content-type and content of file
PosBeg=PosFile + 10
PosEnd=InstrB(PosBeg‚RequestBin‚getByteString(chr(34)))
FileName=getString(MidB(RequestBin‚PosBeg‚PosEnd-PosBeg))
FileName=Mid(FileName‚InStrRev(FileName‚"\")+1)
’Add filename to dictionary object
UploadControl.Add "FileName"‚ FileName
Pos=InstrB(PosEnd‚RequestBin‚getByteString("Content-Type:"))
PosBeg=Pos+14
PosEnd=InstrB(PosBeg‚RequestBin‚getByteString(chr(13)))
’Add content-type to dictionary object
ContentType=getString(MidB(RequestBin‚PosBeg‚PosEnd-PosBeg))
UploadControl.Add "ContentType"‚ContentType
’Get content of object
PosBeg=PosEnd+4
PosEnd=InstrB(PosBeg‚RequestBin‚boundary)-2
Value=FileName
ValueBeg=PosBeg-1
ValueLen=PosEnd-Posbeg
Else
’Get content of object
Pos=InstrB(Pos‚RequestBin‚getByteString(chr(13)))
PosBeg=Pos+4
PosEnd=InstrB(PosBeg‚RequestBin‚boundary)-2
Value=getString(MidB(RequestBin‚PosBeg‚PosEnd-PosBeg))
ValueBeg=0
ValueEnd=0
End If
UploadControl.Add "Value" ‚ Value
UploadControl.Add "ValueBeg" ‚ ValueBeg
UploadControl.Add "ValueLen" ‚ ValueLen
UploadRequest.Add name‚ UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary)‚RequestBin‚boundary)
Loop
End Sub
’====================================
Function getByteString(StringStr)
’====================================
For i=1 to Len(StringStr)
char=Mid(StringStr‚i‚1)
getByteString=getByteString & chrB(AscB(char))
Next
End Function
’====================================
Function getString(StringBin)
’====================================
getString =""
For intCount=1 to LenB(StringBin)
getString=getString & chr(AscB(MidB(StringBin‚intCount‚1)))
Next
End Function
%>
声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。如有疑问请与站长联系。
相关链接更多...
- FSO专题--文件的读出编辑管理 2006-2-28
- ASP中FSO的神奇功能-FSO不能做到的 2006-2-28
- FSO专题--ASP中FSO的神奇功能-写文件2006-2-28
- FSO专题--ASP中FSO文件读取2006-2-28
- FSO专题-- ASP中FSO的神奇功能-用FSO进行内容管理 2006-2-28
- FSO专题--一个老哥写的无组件上传2006-2-28
网友评论
目前没有评论!
全站精华
- 时尚插画家—梁毅作品展[图]
- 香港经典插画作品[图]
- 一套韩国壁纸设计[图]
- asp程序错误详细说明例表
- blog的rss2.0
- asp图片验证码
- 韩国Q版插画欣赏<一>[图]
- 韩国Q版插画欣赏<二>[图]
- 韩国Q版插画欣赏<三>[图]
- 网站推广--网页针对搜索引擎的加注技巧
- Google发布在线网页制作工具[图]
- 粉可爱的韩国插画欣赏(一) [图]
- 粉可爱的韩国插画欣赏(二)[图]
- 粉可爱的韩国插画欣赏(三)[图]
- 粉可爱的韩国插画欣赏(四)[图]
- 苹果NANA的精彩插画作品欣赏[图]
- 苹果NANA的精彩插画作品2[图]
- 王华精彩平面设计欣赏:《白光系列》1[图]
- 王华精彩平面设计欣赏2[图]
- 王华精彩平面设计欣赏:《白光系列》3[图]
- 王华精彩平面设计欣赏4[图]
- 风里面的白嫁衣-漂亮新娘! [图]
- 王华设计欣赏3[图]
- 王华设计欣赏《夜精灵》4[图]
- 超有创意的Shopping包装袋!![图]
- 欧美流行本质色婚纱礼服[1][图]
- 欧美流行本质色婚纱礼服[2][图]
- 陈幼坚包装设计欣赏[图]
- 清风楼书(一)[图]
- 清风楼书(二)[图]
图文精彩
![清风楼书(一)[图]--平面广告](http://www.fansart.com/uploadfile/200642868655905.gif)
【2006-3-29 10:52:08】
清风楼书(一)
清风楼书(一)
![painter超级可爱的上色过程(韩国)[图]--CG插画](http://www.fansart.com/uploadfile/200641150378565.jpg)
【2006-4-5 8:52:28】
painter超级可爱的上色过程(韩国)
painter超级可爱的上色过程(韩国)
![古典楼书(精品欣赏)(1)[图]--平面广告](http://www.fansart.com/uploadfile/200641153842877.jpg)
【2006-4-5 15:03:08】
古典楼书(精品欣赏)(1)
古典楼书(精品欣赏)(1)
![北邦插画欣赏(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641335800545.jpg)
【2006-4-13 9:49:02】
北邦插画欣赏(1)
北邦插画欣赏(1)

【2006-4-13 18:32:29】
yashasi插画作品欣赏
yashasi插画作品欣赏

【2006-4-14 9:21:18】
cg插画欣赏
cg插画欣赏
![溯源居广告欣赏--小红人[图]--平面广告](http://www.fansart.com/uploadfile/200641453136345.jpg)
【2006-4-14 14:45:57】
溯源居广告欣赏--小红人
溯源居广告欣赏--小红人
![房地产广告设计-之水墨风格1[图]--平面广告](http://www.fansart.com/uploadfile/200641457308753.jpg)
【2006-4-14 15:56:06】
房地产广告设计-之水墨风格1
房地产广告设计-之水墨风格1
![泊林花园推广故事绘本(1)[图]--CG插画](http://www.fansart.com/uploadfile/200642041664949.jpg)
【2006-4-20 11:34:33】
泊林花园推广故事绘本(1)
泊林花园推广故事绘本(1)
![泊林花园推广故事绘本(2)[图]--CG插画](http://www.fansart.com/uploadfile/200642042197577.jpg)
【2006-4-20 11:43:23】
泊林花园推广故事绘本(2)
泊林花园推广故事绘本(2)
![万科西山庭院.格.沉.尊[图]--平面广告](http://www.fansart.com/uploadfile/200642133015939.jpg)
【2006-4-21 9:08:35】
万科西山庭院.格.沉.尊
万科西山庭院.格.沉.尊
![2006夏日流行时尚,创意无限街头华丽[图]--时装魅影](http://www.fansart.com/uploadfile/200642261089093.jpg)
【2006-4-22 16:46:51】
2006夏日流行时尚,创意无限街头华丽
2006夏日流行时尚,创意无限街头华丽
![水木清华地产广告欣赏[图]--平面广告](http://www.fansart.com/uploadfile/200642634295921.jpg)
【2006-4-26 9:31:54】
水木清华地产广告欣赏
水木清华地产广告欣赏

【2006-4-26 13:34:46】
Natascha Roeoesli的人物CG插画作品欣赏(1)
Natascha Roeoesli的人物CG插画作品欣赏(1)

【2006-4-26 14:27:13】
新锐CG插画 Monday to Friday
新锐CG插画 Monday to Friday
![经典样本设计欣赏(国人作品)1[图]--平面广告](http://www.fansart.com/uploadfile/200642664631465.jpg)
【2006-4-26 17:57:18】
经典样本设计欣赏(国人作品)1
经典样本设计欣赏(国人作品)1

【2006-5-8 9:52:42】
MIKE H的CG插画作品欣赏(1)
MIKE H的CG插画作品欣赏(1)

【2006-5-8 11:37:48】
韩国品牌YSB夏装 冷艳美人异国风情(3)
韩国品牌YSB夏装 冷艳美人异国风情(3)
![人像摄影:《炫影》(1)[图]--摄影艺术](http://www.fansart.com/uploadfile/20065966294533.gif)
【2006-5-9 18:18:49】
人像摄影:《炫影》(1)
人像摄影:《炫影》(1)

【2006-5-10 18:31:05】
风景摄影欣赏molnies 1
风景摄影欣赏molnies 1