asp 中使用Ftp.exe 上传大文件
'参数说明:FTP 服务器 ;帐号 ; 密码 ;要上传的文件名(需要完整路径),FTp虚拟目录名称
Function upFile(ftp_address, ftp_username, ftp_password , uploadfilename, FtpServerName)
Dim oScript, objFSO
Dim TempFilePath
Dim objTextFile, strCMD
Set oScript = CreateObject("WSCRIPT.SHELL")
Set objFSO = CreateObject("Scripting.FileSystemObject")
TempFilePath = objFSO.GetSpecialFolder(2) '临时目录
Set objTextFile = objFSO.CreateTextFile(TempFilePath & "\test.ftp")
objTextFile.WriteLine "open " & ftp_address 'FTP 服务器地址
objTextFile.WriteLine ftp_username '登录FTP的帐号名
objTextFile.WriteLine ftp_password '登录FTP的密码
objTextFile.WriteLine "bin "
objTextFile.WriteLine "cd /" & FtpServerName & "/" 'FTP站点名称
objTextFile.WriteLine "put " & uploadfilename ' 上传文件的路径
objTextFile.WriteLine "bye"
objTextFile.Close
Set objTextFile = Nothing
strCMD = "ftp.exe -s:" & TempFilePath & "\test.ftp"
Call oScript.Run(strCMD, 0, True)
Set objFSO = Nothing
Set oScript = Nothing
End Function
Function upFile(ftp_address, ftp_username, ftp_password , uploadfilename, FtpServerName)
Dim oScript, objFSO
Dim TempFilePath
Dim objTextFile, strCMD
Set oScript = CreateObject("WSCRIPT.SHELL")
Set objFSO = CreateObject("Scripting.FileSystemObject")
TempFilePath = objFSO.GetSpecialFolder(2) '临时目录
Set objTextFile = objFSO.CreateTextFile(TempFilePath & "\test.ftp")
objTextFile.WriteLine "open " & ftp_address 'FTP 服务器地址
objTextFile.WriteLine ftp_username '登录FTP的帐号名
objTextFile.WriteLine ftp_password '登录FTP的密码
objTextFile.WriteLine "bin "
objTextFile.WriteLine "cd /" & FtpServerName & "/" 'FTP站点名称
objTextFile.WriteLine "put " & uploadfilename ' 上传文件的路径
objTextFile.WriteLine "bye"
objTextFile.Close
Set objTextFile = Nothing
strCMD = "ftp.exe -s:" & TempFilePath & "\test.ftp"
Call oScript.Run(strCMD, 0, True)
Set objFSO = Nothing
Set oScript = Nothing
End Function