高分求asp上传组件! 自己完成了任务,好东西大家分享,很不错的,无组件

本人要做一个文件上传的功能,只要可以上传word文挡和zip文挡就可以了
请大家帮忙提供点线索,最好有代码?谢谢。
还有不知现在的无组件上传可不可以实现这个功能
---------------------------------------------------------------

可以,如果不是很大的文件的话
---------------------------------------------------------------

www.5xsoft.com里有个无组件上传文件的源码及使用方法
---------------------------------------------------------------

  1<script language="VBSCRIPT" runat="SERVER">   
  2  
  3'''''''''''''''''''''''''''''''''''''''''''''''''   
  4'   
  5'请保留此信息: 稻香老农制作 http://www.5xSoft.com/   
  6'   
  7'''''''''''''''''''''''''''''''''''''''''''''''''   
  8  
  9dim upfile_5xSoft_Stream   
 10  
 11Class upload_5xSoft   
 12  
 13dim Form,File,Version   
 14  
 15Private Sub Class_Initialize   
 16dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile   
 17dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr   
 18Version="化境编程界HTTP上传程序 Version 1.0"   
 19if Request.TotalBytes<1 then Exit Sub   
 20set Form=CreateObject("Scripting.Dictionary")   
 21set File=CreateObject("Scripting.Dictionary")   
 22set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")   
 23upfile_5xSoft_Stream.mode=3   
 24upfile_5xSoft_Stream.type=1   
 25upfile_5xSoft_Stream.open   
 26upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes)   
 27  
 28vbEnter=Chr(13)&Chr(10)   
 29iDivLen=inString(1,vbEnter)+1   
 30strDiv=subString(1,iDivLen)   
 31iFormStart=iDivLen   
 32iFormEnd=inString(iformStart,strDiv)-1   
 33while iFormStart < iFormEnd   
 34iStart=inString(iFormStart,"name=""")   
 35iEnd=inString(iStart+6,"""")   
 36mFormName=subString(iStart+6,iEnd-iStart-6)   
 37iFileNameStart=inString(iEnd+1,"filename=""")   
 38if iFileNameStart>0 and iFileNameStart<iFormEnd then   
 39iFileNameEnd=inString(iFileNameStart+10,"""")   
 40mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)   
 41iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)   
 42iEnd=inString(iStart+4,vbEnter&strDiv)   
 43if iEnd>iStart then   
 44mFileSize=iEnd-iStart-4   
 45else   
 46mFileSize=0   
 47end if   
 48set theFile=new FileInfo   
 49theFile.FileName=getFileName(mFileName)   
 50theFile.FilePath=getFilePath(mFileName)   
 51theFile.FileSize=mFileSize   
 52theFile.FileStart=iStart+4   
 53theFile.FormName=FormName   
 54file.add mFormName,theFile   
 55else   
 56iStart=inString(iEnd+1,vbEnter&vbEnter)   
 57iEnd=inString(iStart+4,vbEnter&strDiv)   
 58  
 59if iEnd>iStart then   
 60mFormValue=subString(iStart+4,iEnd-iStart-4)   
 61else   
 62mFormValue=""   
 63end if   
 64form.Add mFormName,mFormValue   
 65end if   
 66  
 67iFormStart=iformEnd+iDivLen   
 68iFormEnd=inString(iformStart,strDiv)-1   
 69wend   
 70End Sub   
 71  
 72Private Function subString(theStart,theLen)   
 73dim i,c,stemp   
 74upfile_5xSoft_Stream.Position=theStart-1   
 75stemp=""   
 76for i=1 to theLen   
 77if upfile_5xSoft_Stream.EOS then Exit for   
 78c=ascB(upfile_5xSoft_Stream.Read(1))   
 79If c > 127 Then   
 80if upfile_5xSoft_Stream.EOS then Exit for   
 81stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c)))   
 82i=i+1   
 83else   
 84stemp=stemp&Chr(c)   
 85End If   
 86Next   
 87subString=stemp   
 88End function   
 89  
 90Private Function inString(theStart,varStr)   
 91dim i,j,bt,theLen,str   
 92InString=0   
 93Str=toByte(varStr)   
 94theLen=LenB(Str)   
 95for i=theStart to upfile_5xSoft_Stream.Size-theLen   
 96if i>upfile_5xSoft_Stream.size then exit Function   
 97upfile_5xSoft_Stream.Position=i-1   
 98if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then   
 99InString=i   
100for j=2 to theLen   
101if upfile_5xSoft_Stream.EOS then   
102inString=0   
103Exit for   
104end if   
105if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then   
106InString=0   
107Exit For   
108end if   
109next   
110if InString<>0 then Exit Function   
111end if   
112next   
113End Function   
114  
115Private Sub Class_Terminate   
116form.RemoveAll   
117file.RemoveAll   
118set form=nothing   
119set file=nothing   
120upfile_5xSoft_Stream.close   
121set upfile_5xSoft_Stream=nothing   
122End Sub   
123  
124  
125Private function GetFilePath(FullPath)   
126If FullPath <> "" Then   
127GetFilePath = left(FullPath,InStrRev(FullPath, "\"))   
128Else   
129GetFilePath = ""   
130End If   
131End function   
132  
133Private function GetFileName(FullPath)   
134If FullPath <> "" Then   
135GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)   
136Else   
137GetFileName = ""   
138End If   
139End function   
140  
141Private function toByte(Str)   
142dim i,iCode,c,iLow,iHigh   
143toByte=""   
144For i=1 To Len(Str)   
145c=mid(Str,i,1)   
146iCode =Asc(c)   
147If iCode<0 Then iCode = iCode + 65535   
148If iCode>255 Then   
149iLow = Left(Hex(Asc(c)),2)   
150iHigh =Right(Hex(Asc(c)),2)   
151toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)   
152Else   
153toByte = toByte & chrB(AscB(c))   
154End If   
155Next   
156End function   
157End Class   
158  
159  
160Class FileInfo   
161dim FormName,FileName,FilePath,FileSize,FileStart   
162Private Sub Class_Initialize   
163FileName = ""   
164FilePath = ""   
165FileSize = 0   
166FileStart= 0   
167FormName = ""   
168End Sub   
169  
170Public function SaveAs(FullPath)   
171dim dr,ErrorChar,i   
172SaveAs=1   
173if trim(fullpath)="" or FileSize=0 or FileStart=0 or FileName="" then exit function   
174if FileStart=0 or right(fullpath,1)="/" then exit function   
175set dr=CreateObject("Adodb.Stream")   
176dr.Mode=3   
177dr.Type=1   
178dr.Open   
179upfile_5xSoft_Stream.position=FileStart-1   
180upfile_5xSoft_Stream.copyto dr,FileSize   
181dr.SaveToFile FullPath,2   
182dr.Close   
183set dr=nothing   
184SaveAs=0   
185end function   
186End Class   
187</script>

---------------------------------------------------------------

 1<p>a)只能运行于 Windows2000+IIS 5,不支持 NT4+IIS4 或是 Win98+PWS, 只要在ASP中加上:<br/>
 2<font color="#0000FF"><!--#include FILE="upload_5xsoft.inc"--></font>   
 3就行了<br/>
 4<br/>
 5<br/>   
 6b) 在使用文件上传时, 表单 form 要加上 enctype="multipart/form-data" 即:<br/>
 7<br/>
 8<font color="#0000FF"><form action="" enctype="multipart/form-data" method="post" name="form1"><br/>
 9<input name="text1" type="text" value="abc"/><br/>
10<input name="file" type="file"/><br/>
11<input name="submit" type="submit" value="提交"/> <br/>
12</form></font><br/>
13<br/>
14<br/>
15</p>
1<a name="class"></a>
1<table border="1" bordercolordark="#CCCCCC" bordercolorlight="#000000" cellpadding="3" cellspacing="0" width="23%">
2<tr align="left" valign="middle">
3<td bgcolor="#CCCCCC" height="16" width="13%"> </td>
4<td bgcolor="#F6F6F6" height="16" width="87%"><font color="#000000" size="2">upload_5xsoft的对象</font></td>
5</tr>
6</table>
1<p>如定义一个上传对象<font color="#0000FF"><br/>
2<!--#include FILE="upload_5xsoft.inc"--> <br/>   

<br/>
set upload=new upload_5xsoft 'upload就是一个对象<br/>

 1<table border="1" bordercolordark="#CCCCCC" bordercolorlight="#000000" cellpadding="10" cellspacing="0" width="96%">
 2<tr bgcolor="#F6F6F6">
 3<td colspan="3" height="24"><font size="2">upload_5xsoft 对象成员</font></td>
 4</tr>
 5<tr align="left" valign="top">
 6<td rowspan="9">file</td>
 7<td colspan="2" height="41">文件对象集,(是个dictionary对象)<br/>
 8</td>
 9</tr>
10<tr align="left" valign="top">
11<td colspan="2" height="20">文件对象成员:</td>
12</tr>
13<tr align="left" valign="top">
14<td height="20" width="17%">Count</td>
15<td height="20" width="66%">属性,文件表单的个数</td>
16</tr>
17<tr align="left" valign="top">
18<td height="20" width="17%">FileName</td>
19<td height="20" width="66%">属性,上传文件的名字</td>
20</tr>
21<tr align="left" valign="top">
22<td height="20" width="17%">FileSize</td>
23<td height="20" width="66%">属性,上传文件的大小(为0是表示没有文件)</td>
24</tr>
25<tr align="left" valign="top">
26<td height="20" width="17%">FilePath</td>
27<td height="20" width="66%">属性,上传前文件所在的路径</td>
28</tr>
29<tr align="left" valign="top">
30<td height="20" width="17%">FormName</td>   
31&lt;td height=</tr></table>
Published At
Categories with Web编程
comments powered by Disqus