人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統(tǒng)下載站 > 技術開發(fā)教程 > 詳細頁面

ASP 無組件上傳

ASP 無組件上傳

更新時間:2022-07-02 文章作者:未知 信息來源:網(wǎng)絡 閱讀次數(shù):

ASP 無組件上傳



說明:從網(wǎng)上收集了一部分,自己寫了一部分。主要提升就是對于form的二進制數(shù)據(jù)進行了類封裝,可以容易的得到form內(nèi)的元素的信息。



Form 二進制數(shù)據(jù)格式:



分割標志數(shù)據(jù) + 0x0D0A

元素說明信息 + 0x0D0A0D0A

元素內(nèi)容數(shù)據(jù) + 0x0D0A



分割標志數(shù)據(jù) + 0x0D0A

元素說明信息 + 0x0D0A0D0A

元素內(nèi)容數(shù)據(jù) + 0x0D0A



……



分割標志數(shù)據(jù) + 0x0D0A





1. Upload.htm



<html>

  <head><title>文件上傳</title></head>

  <body>

<form enctype="multipart/form-data" action="upload.asp" method="post">

<input name="text0" type=text value="文本框"><br>

<input name="file1" type=file accept="image/*"><br>

<input name="file2" type=file accept="image/*"><br>

<input type=submit value="上傳">

</form>

  </body>

</html>



2. upload.asp

<!--#include file="upload.inc"-->

<%

'by sam 2004,6

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

response.expires = 0



if request.servervariables("REQUEST_METHOD")="POST" then

response.clear()

response.buffer=true



set uform = new uploadform

uform.find_element "text0"



data = midb(uform.formdata,uform.datastart,uform.datalen)

Response.binaryWrite data

sdata = binarytostring(data)

Response.write sdata

Response.binarywrite stringtobinary(sdata)









uform.find_element "file1"

savefile server.mappath("/recv1.dat"),uform.formdata,uform.datastart,uform.datalen



uform.find_element "file2"

savefile server.mappath("/recv2.dat"),uform.formdata,uform.datastart,uform.datalen





set uform = nothing



end if

%>



3. upload.inc

<%

'by sam 2004,6

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

function savefile(filename,formdata,start,len)



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 formdata

'strm1.savetofile server.mappath("/1.raw"),2

strm1.position = start - 1

strm1.copyto strm2,len

'strm2.savetofile server.mappath("/1.gif"),2

strm2.savetofile filename,2

set strm1=nothing

set strm2=nothing



end function





function simplebinarytostring(binary)

dim i, s

for i = 1 to lenb(binary)

s = s & chr(ascb(midb(binary,i,1)))

next

simplebinarytostring = s

end function



function binarytostring(binary)

dim cl1,cl2,cl3,pl1,pl2,pl3

dim l

cl1 = 1

cl2 = 1

cl3 = 1

l = lenb(binary)



do while cl1<=l

pl3 = pl3 & chr(ascb(midb(binary,cl1,1)))

cl1 = cl1 + 1

cl3 = cl3 + 1

if cl3>300 then

pl2 = pl2 & pl3

pl3 = ""

cl3 = 1

cl2 = cl2 + 1

if cl2>200 then

pl1 = pl1 & pl2

pl2 = ""

cl2 = 1

end if

end if

loop

binarytostring = pl1 & pl2 & pl3

end function





function stringtobinary(string)

dim i, b

for i=1 to len(string)

b = b & chrb(asc(mid(string,i,1)))

next

stringtobinary = b

end function









class uploadform



private sub class_initialize()

datastart = 0

datalen = 0

formsize=request.totalbytes

formdata=request.binaryread(formsize)

'response.write "<br>myclass start<br>"

end sub





private sub class_terminate()

'response.write "<br>myclass over<br>"

end sub



public datastart

public datalen



public formsize

public formdata





public sub find_element( name)



datastart = 0

datalen = 0



bncrlf=chrb(13) & chrb(10)

strname = "name=" & chr(34) & name & chr(34)



spos = 1

epos = 1



k = 0



do while ( spos < formsize)



epos = instrb(spos,formdata,bncrlf)

divider = midb(formdata,spos, epos - spos)

sdivider = binarytostring (divider)

'response.write sdivider & "<br>"

'response.binarywrite divider & "<br>"



spos = epos + 2

epos = instrb(spos,formdata,bncrlf & bncrlf)

header = midb(formdata,spos,epos - spos)

sheader = binarytostring (header)

'response.write sheader & "<br>"

'response.binarywrite header & "<br>"



spos = epos + 4

epos = instrb(spos,formdata,divider)



if instr(sheader,strname) > 0 then

datastart = spos 'base 1

datalen = epos - spos - 2



'response.write "start = " & datastart & "<br>"

'response.write " end = " & datalen & "<br>"

'savefile server.mappath("/output.dat"),formdata, datastart,datalen

exit do



end if





spos = epos



k = k + 1

if ( k > 20 ) then

exit do

end if



loop



end sub

end class



%>

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 兴宁市| 大田县| 西丰县| 铁岭县| 阳信县| 绥阳县| 伊通| 土默特右旗| 芷江| 谷城县| 厦门市| 石城县| 巴塘县| 进贤县| 临城县| 柳州市| 牡丹江市| 泸溪县| 津南区| 平南县| 四子王旗| 云阳县| 西贡区| 萍乡市| 滁州市| 宜阳县| 武威市| 乌兰察布市| 裕民县| 长白| 哈巴河县| 定结县| 酉阳| 临湘市| 梓潼县| 郴州市| 平山县| 定安县| 蓬莱市| 乌兰察布市| 卓尼县|