PosOpenBoundary = PosCloseBoundary PosCloseBoundary = InStrB(PosOpenBoundary + 1,FormData,DivStr) Wend Set GetUpload = Fields End Function
''把二進制字符串轉換成普通字符串函數 Function bin2str(binstr) Dim varlen,clow,ccc,skipflag ''中文字符Skip標志 skipflag=0 ccc = "" If Not IsNull(binstr) Then varlen=LenB(binstr) For i=1 To varlen If skipflag=0 Then clow = MidB(binstr,i,1) ''判斷是否中文的字符 If AscB(clow) > 127 Then ''AscW會把二進制的中文雙字節字符高位和低位反轉,所以要先把中文的高低位反轉 ccc =ccc & Chr(AscW(MidB(binstr,i+1,1) & clow)) skipflag=1 Else ccc = ccc & Chr(AscB(clow)) End If Else skipflag=0 End If Next End If bin2str = ccc End Function
''把普通字符串轉成二進制字符串函數 Function str2bin(varstr) str2bin="" For i=1 To Len(varstr) varchar=mid(varstr,i,1) varasc = Asc(varchar) '' asc對中文字符求出來的值可能為負數, '' 加上65536就可求出它的無符號數值 '' -1在機器內是用補碼表示的0xffff, '' 其無符號值為65535,65535=-1+65536 '' 其他負數依次類推。 If varasc<0 Then varasc = varasc + 65535 End If ''對中文的處理:把雙字節低位和高位分開 If varasc>255 Then varlow = Left(Hex(Asc(varchar)),2) varhigh = right(Hex(Asc(varchar)),2) str2bin = str2bin & chrB("&H" & varlow) & chrB("&H" & varhigh) Else str2bin = str2bin & chrB(AscB(varchar)) End If Next End Function
''取得文件名(去掉Path) Function GetFileName(FullPath) If FullPath <> "" Then FullPath = StrReverse(FullPath) FullPath = Left(FullPath, InStr(1, FullPath, "/") - 1) GetFileName = StrReverse(FullPath) Else GetFileName = "" End If End Function </SCRIPT> <SCRIPT RUNAT=SERVER LANGUAGE=JSCRIPT> function CreateUploadField(){ return new uf_Init() } function uf_Init(){ this.Name = null this.FileName = null this.FilePath = null this.ContentType = null this.Value = null this.Length = null } </SCRIPT> <!----------------------------------------------------> 在提交的葉面使用 <form method="POST" enctype="multipart/form-data"> 保存的葉面 將upload.inc包含 <!--#include file="upload.inc"--> <%
function lngConvert2(strTemp) str1=leftb(strTemp,1) str2=rightb(strTemp,1) lngConvert2 = clng(ascb(str2) + ((ascb(str1) * 256))) end function
function lngConvert(strTemp) str1=leftb(strTemp,1) str2=rightb(strTemp,1) len1=ascb(str1) len2=ascb(str2) lngConvert = clng(ascb(str1) + ascb(str2) * 256) end function
Dim FormData,FormSize FormSize=Request.TotalBytes FormData=Request.BinaryRead(FormSize)
Set Fields = GetUpload(FormData) If Fields("newfile").FileName<>"" Then tempstr=Leftb(Fields("newfile").Value,10) tstr=chrb(255)&chrb(216)&chrb(255)&chrb(224)&chrb(0)&chrb(16)&chrb(74)&chrb(70)&chrb(73)&chrb(70) end if