Coldfusion 如何使用cfscript删除/删除远程FTP文件?
到目前为止,我的脚本用于打开远程FTP连接、更改目录和下载文件。我的最后两个步骤是在完全下载后删除删除文件,然后关闭连接。ACF文档(和cfdocs)似乎对此信息很少。以下是我目前掌握的情况:Coldfusion 如何使用cfscript删除/删除远程FTP文件?,coldfusion,cfml,Coldfusion,Cfml,到目前为止,我的脚本用于打开远程FTP连接、更改目录和下载文件。我的最后两个步骤是在完全下载后删除删除文件,然后关闭连接。ACF文档(和cfdocs)似乎对此信息很少。以下是我目前掌握的情况: ftpConnection = ftpService.open( action = 'open', connection = variables.ftpConnectionName, server = variables.ftpServerName, username = '****
ftpConnection = ftpService.open(
action = 'open',
connection = variables.ftpConnectionName,
server = variables.ftpServerName,
username = '***************',
password = '***************',
secure='true');
if( ftpConnection.getPrefix().succeeded ){
fileList = ftpService.listdir(directory = variables.ftpPath, connection= variables.ftpConnectionName, name='pendingFiles', stopOnError='true').getResult();
if( fileList.recordCount ){
changeFtpConnectionDir = ftpService.changeDir(
connection = variables.ftpConnectionName,
directory = variables.ftpPath);
getFtpConnection = ftpService.getFile(
connection = variables.ftpConnectionName,
remoteFile = fileList.name,
localFile = local.localPath & fileList.name,
failIfExists = false,
timeout = 3000
);
deleteRemoteFile = ftpService.remove(
connection = variables.ftpConnectionName,
remoteFile = fileList.name
};
closeFtp = ftpService.close(
connection = variables.ftpConnectionName
);
};
};
在remoteFile=fileList.name上引发错误。因为我已经更改了目录,所以我不认为我需要在这里放置完整的路径
我把整个脚本都放上去了,因为关于使用更新的ftpServer()函数的资源似乎不多。D'oh-我的问题是输入错误:
deleteRemoteFile = ftpService.remove(
connection = variables.ftpConnectionName,
remoteFile = fileList.name
);// had } instead of )
我仍然会把它作为ftpService()的资源保留下来。始终包含错误消息告诉您的内容。如果解析器不识别括号问题,我会感到惊讶。