哪位老兄能提供非组件asp上传文件的代码?急

phaqyxiao 2001-08-17 03:29:20
我现在下载了一段代码,但运行速度很慢,急急!!
...全文
176 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ba_saner 2001-09-19
  • 打赏
  • 举报
回复
可惜,只能用在win2k iis5,nt4就不行了。可惜
sundna 2001-08-20
  • 打赏
  • 举报
回复
那是当然了!不过传一般的东东还是不错的!:)
phaqyxiao 2001-08-20
  • 打赏
  • 举报
回复
文件超过1M的话,速度很慢。
hareqiqi 2001-08-20
  • 打赏
  • 举报
回复
我要好好研究研究:)
jjdelphi 2001-08-20
  • 打赏
  • 举报
回复
这就是大名鼎鼎的 化境asp无组件上传
phaqyxiao 2001-08-17
  • 打赏
  • 举报
回复
CityHost(市长),能说一下这些代码怎么用。
CityHost 2001-08-17
  • 打赏
  • 举报
回复
这是说明文档的代码.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a { color: #0000FF; text-decoration: underline}
a:hover { color: #FF0000; text-decoration: underline}
-->
</style>
</head>

<body bgcolor="#FFFAF7" text="#000000">
<br>
<font size="3"><br>
</font>
<table width="65%" border="1" cellspacing="0" cellpadding="5" bordercolordark="#CCCCCC" bordercolorlight="#000000" align="center">
<tr bgcolor="#F6F6F6">
<td colspan="3" height="71" align="center" valign="middle"><b><font size="3" color="#000000">化境ASP无组件上传类
- upload_5xsoft 使用手册 1.0<br>
</font></b><font size="3" color="#000000"> </font><font size="2"><br>
稻香老农 <a href="http://www.5xsoft.com/">http://www.5xsoft.com/</a> [ <a href="upclass.zip">下载</a>
]</font></td>
</tr>
</table>
<font size="3"><br>
<br>
<br>
<br>
</font>
<table width="22%" border="1" cellspacing="0" cellpadding="3" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr align="left" valign="middle">
<td height="16" width="14%" bgcolor="#CCCCCC"> </td>
<td height="16" width="86%" bgcolor="#F6F6F6"><font color="#000000" size="2">目
录</font></td>
</tr>
</table>
<p>1.<a href="#about">关于 upload_5xsoft</a><br>
<br>
2.<a href="#note">运行平台与注意事项</a></p>
<p>2.<a href="#class">类的成员与对象</a></p>
<p>3.<a href="#example">使用示例</a></p>
<a name="about"></a><br>
<table width="22%" border="1" cellspacing="0" cellpadding="3" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr align="left" valign="middle">
<td height="16" width="14%" bgcolor="#CCCCCC"> </td>
<td height="16" width="86%" bgcolor="#F6F6F6"><font color="#000000" size="2">关于
upload_5xsoft</font></td>
</tr>
</table>
<p><font color="#FF0000"><br>
</font></p>
<p>    一直以来,由于FileSystemObject的局限,所以ASP最大的难题就是文件上传,大多解决法就是安装<br>
<br>
第三方上传组件。可第三方组件有很多问题,有的组件要注册,有的组件要在表单中加上他的版权信息。<br>
<br>
还有的就是组件的兼容问题。<br>
<br>
   在网上也流传了很多无组件上传的代码,但都是只能上传文本文件,或是只能将文件上传到数据库中。<br>
<br>
我这段时间在研究ASP,发现可以不用第三方组件上传任意类型的文件。就写了这个类,给大家一<br>
<br>
个方便,整个类放在一个文件中: <font color="#0000FF">upload_5xsoft.inc </font>在<font color="#0000FF">
Example</font> 目录下还有一个完整的多文件上传示<br>
<br>
例程序,可以直接使用。<br>
<br>
<font color="#0000FF">申明:源代码是完全开放的,可能随意传播,但请保留其完整性,未经作者同意,不得用于商业。</font><br>
<br>
<br>
</p>
<a name="note"></a>
<table width="21%" border="1" cellspacing="0" cellpadding="3" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr align="left" valign="middle">
<td height="16" width="15%" bgcolor="#CCCCCC"> </td>
<td height="16" width="85%" bgcolor="#F6F6F6"><font color="#000000" size="2">运行平台与注意事项</font></td>
</tr>
</table>
<p>a)只能运行于 Windows2000+IIS 5,不支持 NT4+IIS4 或是 Win98+PWS, 只要在ASP中加上:<br>
<font color="#0000FF"><!--#include FILE="upload_5xsoft.inc"--></font>
就行了<br>
<br>
<br>
b) 在使用文件上传时, 表单 form 要加上 enctype="multipart/form-data" 即:<br>
<br>
<font color="#0000FF"><form name="form1" method="post"
action="" enctype="multipart/form-data"><br>
<input type="text" value="abc" name="text1"><br>
<input type=file name="file"><br>
<input type=submit name="submit" value="提交"> <br>
</form></font><br>
<br>
<br>
</p>
<a name="class"></a>
<table width="23%" border="1" cellspacing="0" cellpadding="3" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr align="left" valign="middle">
<td height="16" width="13%" bgcolor="#CCCCCC"> </td>
<td height="16" width="87%" bgcolor="#F6F6F6"><font color="#000000" size="2">upload_5xsoft的对象</font></td>
</tr>
</table>
<p>如定义一个上传对象<font color="#0000FF"><br>
<!--#include FILE="upload_5xsoft.inc"--> <br>
<%<br>
set upload=new upload_5xsoft 'upload就是一个对象<br>
%></font></p>
<table width="96%" border="1" cellspacing="0" cellpadding="10" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr bgcolor="#F6F6F6">
<td colspan="3" height="24"><font size="2">upload_5xsoft 对象成员</font></td>
</tr>
<tr align="left" valign="top">
<td rowspan="9">file</td>
<td height="41" colspan="2">文件对象集,(是个dictionary对象)<br>
</td>
</tr>
<tr align="left" valign="top">
<td height="20" colspan="2">文件对象成员:</td>
</tr>
<tr align="left" valign="top">
<td height="20" width="17%">Count</td>
<td height="20" width="66%">属性,文件表单的个数</td>
</tr>
<tr align="left" valign="top">
<td height="20" width="17%">FileName</td>
<td height="20" width="66%">属性,上传文件的名字</td>
</tr>
<tr align="left" valign="top">
<td height="20" width="17%">FileSize</td>
<td height="20" width="66%">属性,上传文件的大小(为0是表示没有文件)</td>
</tr>
<tr align="left" valign="top">
<td height="20" width="17%">FilePath</td>
<td height="20" width="66%">属性,上传前文件所在的路径</td>
</tr>
<tr align="left" valign="top">
<td height="20" width="17%">FormName</td>
<td height="20" width="66%">属性,文件表单的名字</td>
</tr>
<tr align="left" valign="top">
<td height="19" width="17%">SaveAs</td>
<td height="19" width="66%">方法,储存上传后文件,有一个参数,路径要为真实路径如:</td>
</tr>
<tr align="left" valign="top">
<td height="118" width="17%">例子:</td>
<td height="118" width="66%"><font color="#0000FF">set file=upload.file("file1")
'file1为表单名<br>
<br>
response.write "<br>文件名:"&file.FileName<br>
<br>
response.write "<br>文件大小:"&file.FileSize<br>
<br>
response.write "<br>文件路径:"&file.FilePath<br>
<br>
file.saveAs Server.mappath("/1.jpg")<br>
<br>
set file=nothing</font></td>
</tr>
<tr align="left" valign="top">
<td height="86" rowspan="5">form</td>
<td height="20" colspan="2">表单数据集,(是个dictionary对象)用来代替 Request.Form</td>
</tr>
<tr align="left" valign="top">
<td height="20">count</td>
<td height="20">属性,表单数</td>
</tr>
<tr align="left" valign="top">
<td height="20">exists</td>
<td height="20">方法,检查是否有指定的表单名</td>
</tr>
<tr align="left" valign="top">
<td height="9" colspan="2">更多的用法可看 vbscript 的dictionary对象帮助</td>
</tr>
<tr align="left" valign="top">
<td height="108">例子:</td>
<td height="108"><font color="#0000FF"><br>
'得到text1表单的数据,uplaod就是一开始创建的对象<br>
<br>
sText=upload.form("text1") </font></td>
</tr>
<tr align="left" valign="top">
<td height="86">Version</td>
<td height="108" colspan="2">属性,upload_5xsoft类的版本号,如:<br>
<font color="#0000FF"><br>
response.write upload.Version</font></td>
</tr>
</table>
<p> <br>
</p>
<a name="example"></a>
<table width="23%" border="1" cellspacing="0" cellpadding="3" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr align="left" valign="middle">
<td height="16" width="13%" bgcolor="#CCCCCC"> </td>
<td height="16" width="87%" bgcolor="#F6F6F6"><font color="#000000" size="2">使用示例</font></td>
</tr>
</table>
<p>1.上传一个jpg文件的示例:<br>
<br>
文件1: upload.htm</p>
<font color="#0000FF"><html><title>example</title><br>
<body><br>
<form name="form1" method="post" action="upload.asp"
enctype="multipart/form-data"><br>
<input type=file name="file1"><br>
<input type=submit name="submit" value="提交"><br>
</form><br>
</body> <br>
</html><br>
<br>
<font color="#000000">文件2: upload.asp</font><br>
<br>
<html><title>example</title><br>
<body><br>
<!--#include FILE="upload_5xsoft.inc"--> <br>
<%<br>
set upload=new upload_5xsoft<br>
set file=upload.file("file1")<br>
if file.fileSize>0 then<br>
 file.saveAs Server.mappath("temp.jpg")<br>
 response.write "<br>上传文件:"&file.FileName&"
=> temp.jpg OK!"<br>
 response.write "<br>文件大小:"&file.FileSize<br>
 set file=nothing<br>
end if<br>
set upload=nothing<br>
%></body> <br>
</html><br>
<br>
<font color="#000000">2.列表出有文件表单(多文件上传)</font><br>
<font color="#0000FF"><html><title>example</title><br>
<body><br>
<!--#include FILE="upload_5xsoft.inc"--> <br>
<%<br>
set upload=new upload_5xsoft<br>
for each formName in upload.file<br>
 set file=upload.file(formName)<br>
 if file.FileSize>0 then<br>
  file.SaveAs Server.mappath(file.FileName) <br>
  response.write file.FilePath&file.FileName&" ("&file.FileSize&")
=> "<br>
  response.write file.FileName&" 成功!<br>"<br>
 end if<br>
 set file=nothing<br>
next<br>
set upload=nothing<br>
%> <br>
<br>
</font></font> <br>
你还可能直接使用作者写好了的上传程序在example目录中<br>
<br>
<a href="upclass.zip">立即下载</a><br>
<br>
若程序有问题,请写作者联系 <a href="mailto:getc@163.com">getc@163.com</a><br>
<div align=right>稻香老农 2001年 4月19日</div>
</body>
</html>
<xmp style="visibility:hidden">
CityHost 2001-08-17
  • 打赏
  • 举报
回复
这段代码不错
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

'''''''''''''''''''''''''''''''''''''''''''''''''
'
'请保留此信息: 稻香老农制作 http://www.5xSoft.com/
'
'''''''''''''''''''''''''''''''''''''''''''''''''

dim upfile_5xSoft_Stream

Class upload_5xSoft

dim Form,File,Version

Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
Version="化境编程界HTTP上传程序 Version 1.0"
if Request.TotalBytes<1 then Exit Sub
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)

vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while iFormStart < iFormEnd
iStart=inString(iFormStart,"name=""")
iEnd=inString(iStart+6,"""")
mFormName=subString(iStart+6,iEnd-iStart-6)
iFileNameStart=inString(iEnd+1,"filename=""")
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=inString(iFileNameStart+10,"""")
mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)
if iEnd>iStart then
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
theFile.FileName=getFileName(mFileName)
theFile.FilePath=getFilePath(mFileName)
theFile.FileSize=mFileSize
theFile.FileStart=iStart+4
theFile.FormName=FormName
file.add mFormName,theFile
else
iStart=inString(iEnd+1,vbEnter&vbEnter)
iEnd=inString(iStart+4,vbEnter&strDiv)

if iEnd>iStart then
mFormValue=subString(iStart+4,iEnd-iStart-4)
else
mFormValue=""
end if
form.Add mFormName,mFormValue
end if

iFormStart=iformEnd+iDivLen
iFormEnd=inString(iformStart,strDiv)-1
wend
End Sub

Private Function subString(theStart,theLen)
dim i,c,stemp
upfile_5xSoft_Stream.Position=theStart-1
stemp=""
for i=1 to theLen
if upfile_5xSoft_Stream.EOS then Exit for
c=ascB(upfile_5xSoft_Stream.Read(1))
If c > 127 Then
if upfile_5xSoft_Stream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function

Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function

Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
upfile_5xSoft_Stream.close
set upfile_5xSoft_Stream=nothing
End Sub


Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function

Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function

Private function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
End Class


Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
End Sub

Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=1
if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function
if FileStart=0 or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
upfile_5xSoft_Stream.position=FileStart-1
upfile_5xSoft_Stream.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=0
end function
End Class
</SCRIPT>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧