2

我使用下面的代码通过 FTP 上传文件。从第 9 行到第 14 行,它显示错误“属性'连接'对标签无效。(发现:[连接,本地文件,被动,动作,failifexists,远程文件])”请让我知道我去了哪里错误的。提前致谢

1.<cftry>    
2.  <cfftp connection="Myftp"  
3.  action="open"  
4.  server="#ftpurl#"
5.  username="#form.ftpusername#"
6.  password="#form.ftppassword#">
7.  stoponerror="Yes">

8.  Did it open connection? <cfoutput>#cfftp.succeeded#</cfoutput><br />                            
9.  <cfftp connection = "Myftp"
10. action = "PutFile"
11. localFile="D:\home\\wwwroot\localfile.txt"
12. remoteFile="remotefile.txt"
13. failifexists="no"
14. passive = "Yes">

15. Did it put the file? <cfoutput>#cfftp.succeeded#</cfoutput><br />                       
16. <cfftp action="close" connection="Myftp">
17. <cfcatch>
18.     <cfset errText = "Please enter valid FTP details" />
19.     <cfset err = err + 1 />
20. </cfcatch>          
21.</cftry>
4

5 回答 5

1

根据对问题的评论,这里的“错误”是 CFEclipse 字典文件中的一个错误,导致错误地将“连接”标记为无效属性。

提供的代码是有效的并且可以正确执行。

于 2013-03-04T12:45:42.287 回答
0

第 6 行有一个结束标签,看起来不合适。

6.  password="#form.ftppassword#">
7.  stoponerror="Yes">

应该改为

6.  password="#form.ftppassword#"
7.  stoponerror="Yes">
于 2016-06-21T19:35:51.927 回答
-1

使用<cffile>标签是在服务器上上传文件而不是<cftfp>标签的最佳方法。它既简单又紧凑。看语法。。

<cffile 
action = "upload"
destination = "full pathname"
fileField = "form field"
accept = "MIME type|file type"
attributes = "file attribute or list"
mode = "permission"
nameConflict = "behavior"
result = "result name"> 

例子 :

 <cfset destination = expandPath("www\img\QuesImages") />
 <cffile action="Upload" 
         fileField="QuesPhoto"   <!--name of input tag in form-->
         destination="#destination#" 
         nameConflict="Overwrite" 
         accept="image/jpeg, image/gif, image/png">
于 2013-02-26T17:50:38.737 回答
-2
Correct parameters are 

 9.  <cfftp connection = "Myftp"
10. action = "PutFile"
11. localFile="D:\home\\wwwroot\localfile.txt"
12. remoteFile="remotefile.txt"
13. stoponerror="Yes"
14. passive = "Yes">`
于 2013-02-26T17:20:16.467 回答
-2

您可以使用以下代码上传文件.........代码是单个文件的内容

<cfcatch type="any">
    <cfoutput>#CFCATCH.message#</cfoutput>
    Unable to open FTP. Please check Server / Username / Password and then try again.1
    <cfabort>
</cfcatch>

<cfcatch type="Any">
    <cfoutput>C:#CFCATCH.message#</cfoutput>
    Unable to change directory. Please check server directory and then try again.2
    <cfabort>
</cfcatch>

存在...替换...

文件已存在,无法删除。请检查用户访问。
错误:D:#CFCATCH.message#3

    <cfcatch type="Any">
        <cfoutput>D:#CFCATCH.message#<br />
                    #CFCATCH.Detail#
        </cfoutput><br />
        There was a problem uploading your file. Please check User Access and then try again.4
        <cfabort>
    </cfcatch>
</cftry>

上传您的文件时出现问题。请再试一次。错误:#CFCATCH.message#5

于 2013-03-04T11:46:21.983 回答