分享
 
 
 

DUDU的无组件上传例程

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

'#####################################################################

'备注:我没有验证,提供给大家一种参考!请大家自行验证

'欢迎大家发表你认为好的精彩程序代码

'大风(xuankong) 2000。12。8

'#####################################################################

标题:还是用我的无组件文件上载吧,与ASPCN组件有异曲同工之妙,下面是例程:

作者:DUDU(DUSJ)

时间:2000-12-7 上午 09:48:00

阅读次数:8

详细信息:

-----------------------------

表单填写页的内容:

-----------------------------

<html>

<head>

<meta name="Author" content="Sander Duivestein">

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>将本地的文件上载到数据库</title>

</head>

<body>

<font size="2" size="2"><br>

</font>

<form name="frmUpload" method="post" enctype="multipart/form-data" action="Upload.asp">

<table cellspacing="0" cellpadding="0" width="490">

<tr>

<td width="167">

<p align="right"><font size="2" size="2">请选择文件:</font></p>

</td>

<td width="319"><font size="2" size="2"><input type="file" name="vFileName"></font></td>

</tr>

<tr>

<td align="right" width="167"><font size="2" size="2">文件说明1:</font></td>

<td width="319"><input name="shuoming" size="32" ></font></td>

</tr>

<tr>

<td align="right" width="167"><font size="2" size="2">文件说明2:</font></td>

<td width="319"><input name="shuoming_2" size="32" onchange="isdate1(document.frmUpload.dengji)" </td>

</tr>

<td width="167"></td>

<td width="319">

<p align="left"><font size="2" size="1"><input type="submit" style="background-image: url('images/back.jpg'); cursor: hand; font-sizd: smaller; left: 0px; width: 94; top: 5px; height: 25" value=" 上 载 " style="background-image: url('images/back.jpg'); cursor: hand; font-sizd: smaller; left: 0px; width: 94; top: 5px; height: 25" size="23" ></font></p>

</td>

<tr>

<td colspan="2" align="right" width="487"></td>

</tr>

</table>

</form>

</body>

</html>

----------------------------------

Upload.asp的内容:

----------------------------------

<%

Response.Buffer = TRUE

Response.Clear

byteCount = Request.TotalBytes

RequestBin = Request.BinaryRead(byteCount)

'response.binarywrite requestbin

'取得表单的全部内容

'''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim UploadRequest

Set UploadRequest = CreateObject("Scripting.Dictionary")

' UploadRequest结构将用来存放表单

PosBeg = 1

PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(13)))

boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)

'求字段间的分隔串(即:-----------------------------7d029e347d8 )

boundaryPos = InstrB(1,RequestBin,boundary)

Do until (boundaryPos=InstrB(RequestBin,boundary & StoB("--")))

'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,StoB("Content-Disposition"))

Pos = InstrB(Pos,RequestBin,StoB("name="))

PosBeg = Pos+6

PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(34)))

Name = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg))

PosFile = InstrB(BoundaryPos,RequestBin,StoB("filename="))

PosBound = InstrB(PosEnd,RequestBin,boundary)

' response.write "<hr>"

' response.write "name="&name&"<BR>"

' name为表单项的名字

'Test if object is of file type

If PosFile<>0 AND (PosFile<PosBound) Then

PosBeg = PosFile + 10

PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(34)))

FileName = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg))

' response.write "<BR>"

' response.write "filename="&filename&"<BR>"

' filename为全路径文件名(如果是文件类型话)

UploadControl.Add "FileName", FileName

Pos = InstrB(PosEnd,RequestBin,StoB("Content-Type:"))

PosBeg = Pos+14

PosEnd = InstrB(PosBeg,RequestBin,StoB(chr(13)))

ContentType = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg))

UploadControl.Add "ContentType",ContentType

' response.write "filetype="&ContentType&"<BR>"

' response.write "<BR>"

PosBeg = PosEnd+4

PosEnd = InstrB(PosBeg,RequestBin,boundary)-2

Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)

filesize = Posend - Posbeg

UploadControl.Add "FileSize",filesize

' response.write "value="

' response.binarywrite value

' response.write "<BR>"

Else

Pos = InstrB(Pos,RequestBin,StoB(chr(13)))

PosBeg = Pos+4

PosEnd = InstrB(PosBeg,RequestBin,boundary)-2

Value = BtoS(MidB(RequestBin,PosBeg,PosEnd-PosBeg))

' response.write "value="&value&"<BR>"

' value为表单项的值,如果为文件项,则value为一长串二进制码

End If

UploadControl.Add "Value" , Value

UploadRequest.Add name, UploadControl

'UploadRequest增加一个Key为name的项,此项的value仍是一个dixtionary对象

BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)

Loop

''''''''''''''''''''''''''''''''''''''''''''''''''''''''

contentType = UploadRequest.Item("vFileName").Item("ContentType")

filesize = UploadRequest.Item("vFileName").Item("FileSize")

filepathname = UploadRequest.Item("vFileName").Item("FileName")

filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,""))

filevalue = UploadRequest.Item("vFileName").Item("Value")

shuoming = UploadRequest.Item("shuoming").Item("Value")

shuoming_2 = UploadRequest.Item("shuoming_2").Item("Value")

'取出嵌套的dictionary对象的值,注意dictionary的Key区分大小写!!!

''''''''''''处理数据库'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

set connGraph = server.CreateObject("ADODB.connection")

connGraph.ConnectionString = Application("DNS")

connGraph.Open

Set DB = Server.CreateObject("ADODB.RecordSet")

[1] [2] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有