Coldfusion 将ftp连接名称作为参数传递
我创建了一个Coldfusion 将ftp连接名称作为参数传递,coldfusion,Coldfusion,我创建了一个getImageFile()函数,该函数需要以下参数: ftp连接名称 远程文件 本地文件 在函数中,ColdFusion抛出连接未定义的错误。但是如果我在调用函数中使用ftp连接名称,那么它就可以工作 <cffunction name="getImageFile" access="private" returntype="string" > <cfargument name="ftpcon" type="any" required="yes" >
getImageFile()
函数,该函数需要以下参数:
- ftp连接名称
- 远程文件
- 本地文件
<cffunction name="getImageFile" access="private" returntype="string" >
<cfargument name="ftpcon" type="any" required="yes" >
<cfargument name="remotefile" type="string" required="yes" >
<cfargument name="localfile" type="string" required="yes" >
<cfftp action="GetFile"
connection="#Arguments.ftpcon#"
localfile= "#Arguments.localfile#"
remotefile="#Arguments.remotefile#"
stopOnError="false"
transfermode="binary"
failIfExists="false">
<cfdump var="#cfftp#">
</cffunction>
有什么建议吗?您应该能够从函数中删除connection name参数
ftpcon
。根据(在用法部分下)的说明,对于诸如GetFile
之类的简单操作,不需要它
您不需要为单个简单的FTP操作(如GetFile或PutFile)打开连接
当然,您需要在函数中指定连接的服务器、用户名、密码等
只有当action=“open”
或action=“close”
时,才需要cfftp
标记的connection
属性
这就是说,您还应该能够使用缓存连接(我认为),因为您正试图这样做。请包含错误详细信息,如果需要,我将更新此答案。在什么时候打开连接?请包含错误详细信息。您不需要为单个简单的FTP操作(如GetFile或PutFile)打开连接。从。连接名正在传递给此函数,因此我假定连接正在其他位置打开。