这是我的上传组件原文,vb作的,没有任何问题!<br>
<br>
public bin<br>
private names()<br>
private sizes()<br>
private filenames()<br>
private myposition()<br>
public maxsize<br>
public fcount<br>
<br>
public sub exec()<br>
dim pstart, pend, strboundary, i, str, position<br>
dim spacestr<br>
spacestr = "—————————–"<br>
dim tempbarray, tempstr<br>
tempstr = btos(bin)<br>
strboundary = "content-disposition: form-data"<br>
tempbarray = split(tempstr, strboundary)<br>
fcount = ubound(tempbarray)<br>
<br>
redim names(fcount)<br>
redim sizes(fcount)<br>
redim filenames(fcount)<br>
redim myposition(fcount, 2)<br>
<br>
strboundary = stob(strboundary)<br>
position = instrb(bin, strboundary) + 1<br>
<br>
for i = 0 to fcount – 1<br>
pstart = instrb(position, bin, stob(chr(34))) + 1<br>
pend = instrb(pstart, bin, stob(chr(34)))<br>
names(i) = btos(midb(bin, pstart, pend – pstart))<br>
以上取表单名<br>
<br>
pstart = pend + 1<br>
str = midb(bin, pstart, 15)<br>
position = instrb(str, stob("filename"))<br>
if position > 0 then<br>
pstart = instrb(pstart, bin, stob(chr(34))) + 1<br>
pend = instrb(pstart, bin, stob(chr(34)))<br>
str = btos(midb(bin, pstart, pend – pstart))<br>
if str = empty then<br>
filenames(i) = ""<br>
else<br>
filenames(i) = str<br>
pstart = instrb(pend, bin, stob(vbcrlf & vbcrlf)) + 4<br>
pend = instrb(pstart, bin, stob("——-")) – 2<br>
myposition(i, 0) = pstart<br>
myposition(i, 1) = pend<br>
end if<br>
else<br>
pstart = instrb(pstart, bin, stob(vbcrlf & vbcrlf)) + 4<br>
pend = instrb(pstart, bin, stob("——-")) – 2<br>
myposition(i, 0) = pstart<br>
myposition(i, 1) = pend<br>
end if<br>
position = pend<br>
next<br>
<br>
dim save<br>
save = savetofile()<br>
response.write save & "<br>"<br>
end sub<br>
public function savefile(fieldname, mypath, newname)<br>
dim i, tempname, temptype, p, temppath<br>
dim binarystr() as byte<br>
for i = 0 to fcount – 1<br>
if fieldname = names(i) then<br>
tempname = filenames(i)<br>
p = i<br>
exit for<br>
end if<br>
next<br>
i = p<br>
if tempname <> empty then<br>
if filenames(i) <> "" then<br>
p = instrrev(tempname, ".")<br>
temptype = right(tempname, len(tempname) – p)<br>
temppath = mypath & "\" & newname & "." & temptype<br>
binarystr = midb(bin, myposition(i, 0), myposition(i, 1) – myposition(i, 0))<br>
open temppath for binary as #1<br>
put #1, , binarystr<br>
close #1<br>
savefile = newname & "." & temptype<br>
else<br>
savefile = "0"<br>
end if<br>
else<br>
savefile = "0"<br>
end if<br>
end function<br>
public function getform(fieldname)<br>
dim i, sign, p<br>
for i = 0 to fcount – 1<br>
if fieldname = names(i) then<br>
getform = btos(midb(values(i), 1, lenb(values(i))))<br>
sign = 1<br>
p = i<br>
exit for<br>
end if<br>
next<br>
if sign = 1 then<br>
getform = btos(midb(bin, myposition(p, 0), myposition(p, 1) – myposition(p, 0)))<br>
else<br>
getform = ""<br>
end if<br>
end function<br>
public function getsize(fieldname)<br>
dim i, sign, p<br>
for i = 0 to fcount – 1<br>
if fieldname = names(i) then<br>
sign = 1<br>
p = i<br>
exit for<br>
end if<br>
next<br>
if sign = 1 then<br>
getsize = myposition(p, 1) – myposition(p, 0)<br>
else<br>
getsize = 0<br>
end if<br>
end function<br>
private function btos(binstr)<br>
dim lnglen<br>
dim tmpbin<br>
dim strc<br>
dim skipflag<br>
dim i<br>
中文字符skip标志<br>
skipflag = 0<br>
strc = ""<br>
if not isnull(binstr) then<br>
lnglen = lenb(binstr)<br>
for i = 1 to lnglen<br>
if skipflag = 0 then<br>
tmpbin = midb(binstr, i, 1)<br>
判断是否中文的字符<br>
if ascb(tmpbin) > 127 then<br>
ascw会把二进制的中文双字节字符高位和低位反转,所以要先把中文的高低位反转<br>
strc = strc & chr(ascw(midb(binstr, i + 1, 1) & tmpbin))<br>
skipflag = 1<br>
else<br>
strc = strc & chr(ascb(tmpbin))<br>
end if<br>
else<br>
skipflag = 0<br>
end if<br>
next<br>
end if<br>
btos = strc<br>
end function<br>
<br>
<br>
把普通字符串转成二进制字符串函数<br>
private function stob(varstr)<br>
dim str2bin<br>
dim varchar<br>
dim varasc<br>
dim varlow, varhigh<br>
dim i<br>
str2bin = ""<br>
for i = 1 to len(varstr)<br>
varchar = mid(varstr, i, 1)<br>
varasc = asc(varchar)<br>
asc对中文字符求出来的值可能为负数,<br>
加上65536就可求出它的无符号数值<br>
-1在机器内是用补码表示的0xffff,<br>
其无符号值为65535,65535=-1+65536<br>
其他负数依次类推。<br>
if varasc < 0 then<br>
varasc = varasc + 65535<br>
end if<br>
对中文的处理:把双字节低位和高位分开<br>
if varasc > 255 then<br>
varlow = left(hex(asc(varchar)), 2)<br>
varhigh = right(hex(asc(varchar)), 2)<br>
str2bin = str2bin & chrb("&h" & varlow) & chrb("&h" & varhigh)<br>
else<br>
str2bin = str2bin & chrb(ascb(varchar))<br>
end if<br>
next<br>
stob = str2bin<br>
end function<br>
<br>
<br>
private sub class_terminate()<br>
set bin = nothing<br>
end sub<br>
<br>
<br>
<br>
<br>
<br>
<br>
关于文件上传组件的调试问题
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 关于文件上传组件的调试问题
相关推荐
-      ASP 简介
-      SQL注入天书 – ASP注入漏洞全接触
-      用.net 处理xmlHttp发送异步请求
-      asp.net创建文件夹的IO类的问题
-      如何实现ASP.NET网站个性化
-      关于ASP.NET调用JavaScript的实现
-      ASP利用Google实现在线翻译功能
-      Asp无组件生成缩略图
