<
!
--
= * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = *
* 作 者: 我本有心
= QQ: 381584252
* E - Mail: hztgcl1986@ 163 .com
= 转载请注明出处及作者!
* 版权所有,侵权必究!!!
=
* http: // www.8848so.com,人物搜索,8848So
= * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = *
-->
< %
' 此代码适合有一定ADODB.Stream基础的人阅读
' 这里只有服务器端代码,想必客户端不是问题所在
Dim formsize,formdata,bincrlf,oencrlfplace,twocrlfplace,ext,filepath,p,l
Dim usingstream,stream
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
Set usingstream = Server.CreateObject( " ADODB.Stream " )
usingstream.Type = 1
usingstream.Open()
usingstream.Write(formdata)
bincrlf = ChrB( 13 ) & ChrB( 10 ) ' 二进制回车换行
oencrlfplace = InStrB(formdata,bincrlf) ' 44,第一次回车换行位置
twocrlfplace = InStrB(oencrlfplace + 1 ,formdata,bincrlf) ' 第二次回车换行位置
Set stream = Server.Createobject( " ADODB.Stream " )
stream.Type = 1
stream.Open()
usingstream.Position = oencrlfplace + 1
usingstream.CopyTo stream,twocrlfplace - oencrlfplace - 3 ' 得到第二行数据,twocrlfplace-onecrlfplace-(回车换行长度+"长度)
stream.Position = 0
stream.Type = 2 ' 字符串
stream.CharSet = " GB2312 "
streamtext = stream.Readtext() ' 读取第二行数据
stream.Close()
ext = Mid (streamtext, InstrRev (streamtext, "" ) + 1 ) ' 得到文件名
filepath = Server.MapPath( " upload/ " & ext)
p = InStrB(formdata,bincrlf & bincrlf) + 4 ' 4为两次回车换行长度
l = InStrB(p + 1 ,formdata,LeftB(formdata,oencrlfplace - 1 )) - p - 2 ' 文件内容部分长度,onecrlfplace-1为第一行数据(也是分隔符),2为回车换行长度
stream.Type = 1
stream.Open()
usingstream.Position = p - 1
usingstream.CopyTo stream,l ' 文件内容数据
stream.SaveToFile filepath, 2 ' 保存文件
usingstream.Close(): Set usingstream = Nothing
stream.Close(): Set stream = Nothing
% >
= * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = *
* 作 者: 我本有心
= QQ: 381584252
* E - Mail: hztgcl1986@ 163 .com
= 转载请注明出处及作者!
* 版权所有,侵权必究!!!
=
* http: // www.8848so.com,人物搜索,8848So
= * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = * = = *
-->
< %
' 此代码适合有一定ADODB.Stream基础的人阅读
' 这里只有服务器端代码,想必客户端不是问题所在
Dim formsize,formdata,bincrlf,oencrlfplace,twocrlfplace,ext,filepath,p,l
Dim usingstream,stream
formsize = Request.TotalBytes
formdata = Request.BinaryRead(formsize)
Set usingstream = Server.CreateObject( " ADODB.Stream " )
usingstream.Type = 1
usingstream.Open()
usingstream.Write(formdata)
bincrlf = ChrB( 13 ) & ChrB( 10 ) ' 二进制回车换行
oencrlfplace = InStrB(formdata,bincrlf) ' 44,第一次回车换行位置
twocrlfplace = InStrB(oencrlfplace + 1 ,formdata,bincrlf) ' 第二次回车换行位置
Set stream = Server.Createobject( " ADODB.Stream " )
stream.Type = 1
stream.Open()
usingstream.Position = oencrlfplace + 1
usingstream.CopyTo stream,twocrlfplace - oencrlfplace - 3 ' 得到第二行数据,twocrlfplace-onecrlfplace-(回车换行长度+"长度)
stream.Position = 0
stream.Type = 2 ' 字符串
stream.CharSet = " GB2312 "
streamtext = stream.Readtext() ' 读取第二行数据
stream.Close()
ext = Mid (streamtext, InstrRev (streamtext, "" ) + 1 ) ' 得到文件名
filepath = Server.MapPath( " upload/ " & ext)
p = InStrB(formdata,bincrlf & bincrlf) + 4 ' 4为两次回车换行长度
l = InStrB(p + 1 ,formdata,LeftB(formdata,oencrlfplace - 1 )) - p - 2 ' 文件内容部分长度,onecrlfplace-1为第一行数据(也是分隔符),2为回车换行长度
stream.Type = 1
stream.Open()
usingstream.Position = p - 1
usingstream.CopyTo stream,l ' 文件内容数据
stream.SaveToFile filepath, 2 ' 保存文件
usingstream.Close(): Set usingstream = Nothing
stream.Close(): Set stream = Nothing
% >