我使用下面的代码通过FTP上传文件。从第9行到第14行,ít显示错误:“属性'connection‘对标记无效。(Found: connection,localfile,action,action,failifexists,remotefile)”请告诉我哪里出错了。提前感谢
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>发布于 2013-03-04 20:45:42
根据对这个问题的评论,这里的“错误”是CFEclipse字典文件中的一个错误,导致“连接”被错误地标记为无效属性。
提供的代码是有效的,并且可以正确执行。
发布于 2016-06-22 03:35:52
您在第6行有一个结束标记,它看起来不合适。
6. password="#form.ftppassword#">
7. stoponerror="Yes">应该改为
6. password="#form.ftppassword#"
7. stoponerror="Yes">发布于 2013-02-27 01:50:39
在服务器端上传文件时,最好使用<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">https://stackoverflow.com/questions/15085349
复制相似问题