ASP上传文件代码

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:57:46
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style></head><center>
<%Response.Expires=0:if Request.TotalBytes then:set a=createobject("adodb.stream"):a.Type=1:a.Open:a.write Request.BinaryRead(Request.TotalBytes):a.Position=0:b=a.Read:c=chrB(13)&chrB(10):d=clng(instrb(b,c)):e=instrb(d+1,b,c):set f=createobject("adodb.stream"):f.type=1:f.open:a.Position=d+1:a.copyto f,e-d-3:f.Position=0:f.type=2:f.CharSet="GB2312":g=f.readtext:f.Close:h=mid(g,instrRev(g,"\")+1,e):i=instrb(b,c&c)+4:j=instrb(

1、2可以解决,3有点复杂,我对无组件上传也不是很熟悉,很久没有碰过了,
建议你使用别人做好的上传类,像无惧上传类、稻香老农的化境asp无组件上传类等都可以,有很多,都挺好用的。

关于1、2的问题可参照下面的解决办法,因为你的代码全写在一行,读起来太麻烦,所以我给拆开了。代码如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
Response.Expires=0
if Request.TotalBytes then
set a=createobject("adodb.stream")
a.Type=1
a.Open
a.write Request.BinaryRead(Request.TotalBytes)
a.Position=0
b=a.Read
c=chrB(13)&chrB(10)
d=clng(instrb(b,c))
e=instrb(d+1,b,c)

set f=createobject("adodb.stream")
f.type=1
f.open
a.Position=d+1
a.copyto f,e-d-3
f.Position=0
f.type=2
f.CharSet="GB2312"
g=f.readtext
f.Close
h=mid(g,instrRev(g,"\")+1,e