能否在ASP中运用FTP协议传输文件到服务器吗?

bigspook 2003-08-12 04:59:40
我想做一套纯“傻瓜”式的视频点播系统,日常维护希望越简单越好,所以我就考虑是否让客户象上传小图片一样通过页面上一个简单的操作而把巨大的视频文件从任何客户机上传到服务器,这么大的文件传输,我只有想到FTP了!
还请各位大哥多提宝贵意见!
哪怕是一个思路也好!
谢谢了!
...全文
52 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccmoon 2003-08-12
  • 打赏
  • 举报
回复
实际上是两部分,上面的代码是自动生成下面的txt文件
asp文件
<%
Set oScript = server.CreateObject("WSCRIPT.SHELL")
Call oScript.Run ("cmd.exe /c " & "ftp.exe -s:d:/smbcris/files/ftp.txt" & " > " & temp, 0, True)
Set oScript = Nothing
%>


ftp.txt文件,这是ftp命令
lcd D:\SmbcRIS\files\download
open 172.28.176.58
chenhy
111
cd /swift/localhost/CNSH/Incoming
prompt
mget *.out

cd /swift/localhost/CNSH/Save_Incoming
mput *.out
bye

notes:
另外还有很多控件可以解决,不过都需要花钱
你可以在google搜索 asp ftp控件
ccmoon 2003-08-12
  • 打赏
  • 举报
回复
不用客气

<html>
<head>
<title>ftp</title>
</head>

<body>

<%
Dim objFSO, objTextFile, oScript, oScriptNet, oFileSys, oFile, strCMD, strTempFile, strCommandResult
Dim ftp_address, ftp_username, ftp_password, ftp_physical_path, ftp_files_to_put

' Edit these variables to match your specifications
ftp_address = "172.28.176.58"
ftp_username = "chenhy"
ftp_password = "111"
ftp_remote_directory = ""
ftp_files_to_get = "*.zip"

On Error Resume Next
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Build our ftp-commands file
Set objTextFile = objFSO.CreateTextFile(Server.MapPath("test.ftp"))
objTextFile.WriteLine "lcd " & Server.MapPath(".")
objTextFile.WriteLine "open " & ftp_address
objTextFile.WriteLine ftp_username
objTextFile.WriteLine ftp_password

' Check to see if we need to issue a 'cd' command
If ftp_remote_directory <> "" Then
objTextFile.WriteLine "cd " & ftp_remote_directory
End If

objTextFile.WriteLine "prompt"

' If the file(s) is/are binary (i.e. .jpg, .mdb, etc..), uncomment the following line
' objTextFile.WriteLine "binary"
If Instr(1, ftp_files_to_get, "*",1) Then
objTextFile.WriteLine "mget " & ftp_files_to_get
Else
objTextFile.WriteLine "get " & ftp_files_to_get
End If

objTextFile.WriteLine "bye"
objTextFile.Close

Set objTextFile = Nothing
' Use cmd.exe to run ftp.exe, parsing our newly created command file
strCMD = "ftp.exe -s:" & Server.MapPath("test.ftp")
strTempFile = "c:\" & oFileSys.GetTempName( )

' Pipe output from cmd.exe to a temporary file (Not :| Steve)
Call oScript.Run ("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (strTempFile, 1, False, 0)

On Error Resume Next
' Grab output from temporary file
strCommandResult = Server.HTMLEncode( oFile.ReadAll )
oFile.Close

' Delete the temporary & ftp-command files
Call oFileSys.DeleteFile( strTempFile, True )
Call objFSO.DeleteFile( Server.MapPath("test.ftp"), True )
Set oFileSys = Nothing
Set objFSO = Nothing

' Print result of FTP session to screen
Response.Write( Replace( strCommandResult, vbCrLf, "<br>", 1, -1, 1) )

%>




</body>
</html>
sailor001 2003-08-12
  • 打赏
  • 举报
回复
直接不能脚本连接ftp
可以通过组件连接
ccmoon 2003-08-12
  • 打赏
  • 举报
回复
可以用ftp
WSCRIPT.SHELL
Scripting.FileSystemObject
可以解决

28,391

社区成员

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

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