★★★★★ 100分 求文件上传下载的代码或组件,分不够再加★★★★★

ricky460 2003-11-05 02:36:45
客户端目录为f:\a ,
服务器端目录为 e:\b ,
要求将客户端f:\a目录下所有文件以及子目录全部都拷贝到服务器端e:\b 下 .
同时也能够将服务器端e:\b目录下所有文件子目录和文件全都拷贝到客户端f:\a下...

求相应的代码 或者免费组件 . . . . . .
最好是直接能用的javascript的asp代码 . . . .

分不是问题 . . . 100 分不另外开贴再给 . . . .
...全文
62 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaiyf 2003-11-11
  • 打赏
  • 举报
回复
ding !ding !ding !
ding !ding !
ding !
damboo 2003-11-11
  • 打赏
  • 举报
回复
如果采用HTTP上传方式,也就是说客户端不用任何控件的话,如果上传的文件小,建议使用无组件上传,如果文件很大,建议使用abcupload,几百兆没有问题(在论坛搜索一下,可以找到安装序列号)
这种上传方式必须一个一个的选择文件,不能批量上传文件或者上传整个目录
我以前做过一个项目,要求用户直接选中多个文件,或者选择目录进行上传,这种就必须使用客户端的控件了。当时采用了两种方案,一个是用控件在客户端对文件进行压缩,压成一个文件后上传,上传后在用组件解开。
另一种是开一个ftp帐号,把密码和用户名都内置在控件中,在ActiveX控件中进行ftp上传

下载整个目录我是用组件压缩的方法实现的,效率低的难以忍受,请高手们指教
nchen123 2003-11-11
  • 打赏
  • 举报
回复
呵呵,客气了,我来看看。

分数就散给其他人吧!
ricky460 2003-11-11
  • 打赏
  • 举报
回复
谢谢 inelm(Archimond) 的代码....
并谢谢 damboo(淡泊) 和xxrl(孔曰成仁,孟曰取E) 的关注...
我会到xxrl的贴子里好好研究的 . . . . :)
xxrl 2003-11-11
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2437/2437534.xml?temp=.3685877
那里有你要的东西.
DeltaCat 2003-11-11
  • 打赏
  • 举报
回复
TO: yongmei123(yueer)

升级你的ADO版本,目前,MDAC最新版为 2.8
去MOCROSOFT DOWN吧
yongmei123 2003-11-07
  • 打赏
  • 举报
回复
我运行sjzxj(sjzxj)大师发送的帖子有以下错误:请教为什么?
错误 '80040111'
ClassFactory 无法供应请求的类别

/www/upload.asp,行17
17行是这句话:set upfile_5xSoft_Stream=CreateObject("Adodb.Stream")
谢谢大师们
ricky460 2003-11-05
  • 打赏
  • 举报
回复
Sa-FileUp官方下载地址: http://www.softartisans.com , 不过需要数百美元 . . .
很贵哦...
tandry 2003-11-05
  • 打赏
  • 举报
回复
sa-fileup组件怎么用?谁会呢?
jiank 2003-11-05
  • 打赏
  • 举报
回复
建立一个权限用户表,设置各个用户的权限,再判断存盘的目录,不符合就跳出。
iamsangster 2003-11-05
  • 打赏
  • 举报
回复
请问哪儿有sa-fileup组件下载?
ricky460 2003-11-05
  • 打赏
  • 举报
回复
谢谢 sjzxj(sjzxj) 发送的帖子 . . . 上面的代码曾经下载测试过 . . .
能工作,不过当文件比较大的时候,速度非常慢 . . . .
另外 , 我是目录下所有的文件和子目录都需要要下载或者上传 . . .
上面的代码可能不能满足需求 . . . .
另外,我自己下载了几个组件做了测试 , 用了一个50M的文件做测试,
速度都不能令人满意 , 基本上到后来都进入了死机状态. . . .

所以,我决定改成假设FTP网站,用FTP来进行上传下载 . . . . . .

现在我想请问: 我希望对于FTP下每一个目录设置一个权限 .
比如设置e:\test目录只能由用户x来访问 , 我该如何通过
代码来实现 . . . . . . . .???
sjzxj 2003-11-05
  • 打赏
  • 举报
回复
保存页面upload-save.asp
<!--#include FILE="upload.asp"-->
<html>
<head>
<title>文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<BODY>
<%
Dim Conn,Rs_News,cpm,upload,file,formName,formPath,filename
Set Conn = server.CreateObject("ADODB.CONNECTION")
cpm="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("book.mdb")
Conn.Open cpm

set upload=new upload_5xSoft
class_xx=upload.form("class_xx")
formPath=upload.form("filepath")
set file=upload.file("file1")
gsid=upload.form("gsid")
diqu=upload.form("diqu")
hy=upload.form("hy")
xxzht=trim(upload.form("xxzht"))
fbgs=trim(upload.form("fbgs"))
xxjj=trim(upload.form("xxjj"))
xxnr=trim(upload.form("xxnr"))

if file.FileSize>0 then
dim a
a=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&right(trim(file.FileName),4)
filename="down\"&a
file.SaveAs Server.mappath(filename)
end if
select case class_xx
case 1
Sql="insert into gsxx(gsid,diqu,hy,xxzht,fbgs,xxjj,xxnr) values('"&gsid&"',"&diqu&","&hy&",'"&xxzht&"','"&fbgs&"','"&xxjj&"','"&xxnr&"')"
conn.execute Sql
case 2
Sql="insert into zhfxx(gsid,diqu,hy,xxzht,fbgs,xxjj,xxnr) values('"&gsid&"',"&diqu&","&hy&",'"&xxzht&"','"&fbgs&"','"&xxjj&"','"&xxnr&"')"
Conn.Execute Sql
case 3
Sql="insert into zlxz(diqu,xxzht,xxjj,xxnr,xzurl) values("&diqu&",'"&xxzht&"','"&xxjj&"','"&xxnr&"','"&filename&"')"
Conn.Execute Sql
end select
set file=nothing
set upload=nothing
conn.close
set conn=Nothing
%>
<center><br>
<br><br><br><br><font color=red><b>请稍等,正在保存信息...</b></font></center>
<form name=loading>
<p align=center>
<font color="#0066ff" size="2" face="Arial">loading...</font><input type=text name=chart
size=46 style="font-family:Arial; font-weight:bolder; color:#0066ff; background-color:white;
padding:0px; border-style:none;"> <br> <input type=text name=percent size=47
style="color:#0066ff; text-align:center; border-width:medium; border-style:none;">
<script>
var bar=0
var line="||"
var amount="||"
count()
function count(){
bar=bar+2
amount =amount + line
document.loading.chart.value=amount
document.loading.percent.value=bar+"%"
if (bar<99)
{setTimeout("count()",100);}

}</script></p></form><br>
<center>
<font color=red><b>数据保存完成后,自动返回!!!!!!!!!!!!!</b></font>
</center>
<meta http-equiv="refresh" content="5;url=upload.asp">
</body>
</html>


upload.asp文件
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>

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=""
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>

数据库自己建!!
sjzxj 2003-11-05
  • 打赏
  • 举报
回复
信息填写页面:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>信息</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.3502.5390" name=GENERATOR><LINK
href="img/whole.css" rel=stylesheet type=text/css>
<SCRIPT language=JavaScript>
function checkdata()
{
if (document.will.class_xx.value==5)
{
alert("请选择信息类别!");
document.will.class_xx.focus();
return false;
}
}
</SCRIPT>
</HEAD>
<BODY leftMargin=0 text=#000000
topMargin=0>
<table width="500" border="0" align="center">
<tr>
<td><FORM action= upload-save.asp method="post" enctype="multipart/form-data" name=will onSubmit="return checkdata()">
<DIV align=center>
<TABLE border=0 borderColor=#111111 cellPadding=0 cellSpacing=0 id=AutoNumber1
style="BORDER-COLLAPSE: collapse" width=487>
<TBODY>
<TR>
<TD width=21> <P align=right><IMG border=0 src="image/r1.gif"></P></TD>
<TD background=image/r_bgtop.gif width=458> <P align=center> </P></TD>
<TD width=21><IMG border=0 src="image/r2.gif"></TD>
</TR>
<TR>
<TD background=image/r_bgleft.gif width=21></TD>
<TD width=458> <table width="100%" height="100%" border="0">
<tr>
<td width="50%"><div align="center">管理 <font color="#FF0000"><a href="admin.asp?class_xx=1" target="_self">企业信息</a> <a href="admin.asp?class_xx=2" target="_self">政府信息</a> <a href="admin.asp?class_xx=3" target="_self">资料下载</a></font></div></td>
<td width="50%"><div align="center"><strong><font color="#FF0000"><a href="upload.asp" target="_self">填加信息</a></font></strong></div></td>
</tr>
</table></TD>
<TD background=image/r_bgright.gif width=21> </TD>
</TR>
<TR>
<TD colSpan=3><IMG border=0 src="image/r_center.gif"></TD>
</TR>
<TR>
<TD width=21 height="109" background=image/r_bgleft.gif> <P> </P></TD>
<TD width=458> <table width="100%" border="0">
<tr>
<td><div align="center"><strong>信息类别:</strong></div></td>
<td><select name="class_xx">
<option value="5" selected>必须选择</option>
<option value="1">企业信息</option>
<option value="2">政府信息</option>
<option value="3">资料下载</option>
</select>
</td>
</tr>
<tr>
<td width="20%"><div align="center"><strong>您的注册号:</strong></div></td>
<td width="80%"><input name="gsid" type="text" id="gsid" size="12" maxlength="10">
</td>
</tr>
<tr>
<td><div align="center"><strong>所在地区:</strong></div></td>
<td><select name="diqu" id="diqu">
<option value="100" selected>所有地区</option>

<option value="107">廊坊</option>
<option value="108">唐山</option>
<option value="110">秦皇岛</option>
<option value="111">张家口</option>
</select>
</td>
</tr>
<tr>
<td><div align="center"><strong>所属行业:</strong></div></td>
<td><SELECT name=hy id="hy"
style="BORDER-BOTTOM: #006b66 1px solid; BORDER-LEFT: #006b66 1px solid; BORDER-RIGHT: #006b66 1px solid; BORDER-TOP: #006b66 1px solid; FONT-SIZE: 10pt">
<option value="325">医疗、保健</option>
<option value="326">商业服务</option>
<option value="327">综合性公司</option>
<option value="300" selected>所有行业</option>
</SELECT>
</td>
</tr>
<tr>
<td><div align="center"><strong>信息主题:</strong></div></td>
<td><input name="xxzht" type="text" id="xxzht" size="20" maxlength="20">
</td>
</tr>
<tr>
<td><div align="center"><strong>公司名称:</strong></div></td>
<td><input name="fbgs" type="text" id="fbgs" size="25" maxlength="25">
</td>
</tr>
<tr>
<td height="16"><div align="center"><strong>信息介绍:</strong></div></td>
<td><input name="xxjj" type="text" id="xxjj" size="30" maxlength="50">
</td>
</tr>
<tr>
<td><div align="center"><strong>请选择文件:</strong></div></td>
<td><INPUT TYPE="file" NAME="file1"><input type="hidden" name="filepath" value="<%=Session(" path")%>">
</td>
</tr>
<tr>
<td><div align="center"><strong>详细内容:</strong></div></td>
<td><textarea name="xxnr" cols="48" rows="10" id="xxnr"></textarea></td>
</tr>
</table>
</TD>
<TD background=image/r_bgright.gif width=21></TD>
</TR>
<TR>
<TD width=21> <P align=right><IMG border=0 src="image/r3.gif"></P></TD>
<TD background=image/r_bgend.gif width=458>  </TD>
<TD width=21><IMG border=0
src="image/r4.gif"></TD>
</TR>
</TBODY>
</TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="50%">
<TBODY>
<TR>
<TD> <DIV align=center>
<input type="submit" name="Submit" value="提 交">
</DIV></TD>
<TD> <DIV align=center>
<input type="reset" name="Submit2" value="重 填">
</DIV></TD>
</TR>
</TBODY>
</TABLE>
</DIV>
</FORM></td>
</tr>
</table>
</BODY></HTML>
lencho2003 2003-11-05
  • 打赏
  • 举报
回复
用不惧上传类啊,网上到处都有下,还有说明,好用得很

28,391

社区成员

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

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