Copy link to clipboard
Copied
<cfset ftpurl=ftp.myserver.com>
<cfset ftpusername="myusername">
<cfset ftppassword="mypassowrd">
<cfset ftplocal="C:\Users\MyUser\Documents\MyFile.txt">
<cfset ftpremote="MyFile.txt">
<cfftp connection = "Myftp"
action = "PutFile"
localFile="#ftplocal#"
remoteFile="#ftpremote#"
failifexists="no"
passive = "Yes">
I use above code to copy a local file from local machine to FTP server.
I checked that the file exists and spelling is correct, but I got following error
(The system cannot find the path specified).
Any suggestions is great appreciated,
Regards,
Souries
iccsi wrote
I use cfoutput to check the file name using CFFILE UPLOAD and see the file name change to localhost tmp folder,
Is it possible that the I need use CFFILE UPLOAD to the server and using FTP PutFile using the server temp file, if yes, are there any sample code to access this temp file for FTP PutFile.
Thanks again for helping,
\MyApp\runtime\work\Catalina\localhost\tmp\
This question now makes me guess that you have 3 separate machines: your local Windows, the machine hosting ColdFusion an
...Copy link to clipboard
Copied
One way I like to diagnose problems like this is to use something like Wireshark to track traffic between the client and the server. This should let you know more about what the two machines are saying to each other. If you have logging as an option on the FTP server, you might be able to get that information that way, instead.
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
Have you tried setting an absolute path for the remote file?
Copy link to clipboard
Copied
<cfset ftpurl="ftp.myserver.com"><!---Thanks to Charlie Arehart --->
<cfset ftpusername="myusername">
<cfset ftppassword="mypassowrd">
<cfset ftplocal="C:\Users\MyUser\Documents\MyFile.txt">
<cfset ftpremote="MyFile.txt">
<!--- Open the connection --->
<cfftp action = "open"
username = "#ftpusername#"
password = "#ftppassword#"
connection = "myConnection"
server = "#ftpurl#"
stopOnError = "Yes">
<p>Did opening the connection succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
<!--- Put the file--->
<cfftp connection = "myConnection"
name = "myFile"
action = "PutFile"
localFile="#ftplocal#"
remoteFile="#ftpremote#"
failifexists="no"
passive = "Yes">
<p>Close the connection</p>
<cfftp action = "close"
connection = "myConnection"
stopOnError = "Yes">
<p>Did closing it succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
Copy link to clipboard
Copied
I follow your Charlie Arehart example code, I still get same error,
(The system cannot find the path specified)
Regards,
Iccsi
Copy link to clipboard
Copied
An error occurred during the FTP PutFile operation
Error: C:/Users/MyUser/Documents/MyFile.txt (The system cannot find the path specified).
Here is my error message,
It looks like the error message change the slash direction
Code is like
<cfset ftplocal="C:\Users\MyUser\Documents\MyFile.txt">
but error message is the other way
Error: C:/Users/MyUser/Documents/MyFile.txt (The system cannot find the path specified).
Any thought for this?
Your information and help is great appreciated,
Regards,
Copy link to clipboard
Copied
iccsi wrote
An error occurred during the FTP PutFile operation
Error: C:/Users/MyUser/Documents/MyFile.txt (The system cannot find the path specified).
Here is my error message,
It looks like the error message change the slash direction
Code is like
<cfset ftplocal="C:\Users\MyUser\Documents\MyFile.txt">
but error message is the other way
Error: C:/Users/MyUser/Documents/MyFile.txt (The system cannot find the path specified).
Hi iccsi​
ColdFusion will accept both the forward slash and the backward slash. I think the problem is that the file doesn't exist.
To be sure, you could do something like this:
<cfset ftpurl="ftp.myserver.com">
<cfset ftpusername="myusername">
<cfset ftppassword="mypassowrd">
<cfset ftplocal="C:\Users\MyUser\Documents\MyFile.txt">
<cfset ftpremote="MyFile.txt">
<cfif fileExists(ftplocal)>
<!--- Open the connection --->
<cfftp action = "open"
username = "#ftpusername#"
password = "#ftppassword#"
connection = "myConnection"
server = "#ftpurl#"
stopOnError = "Yes">
<p>Did opening the connection succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
<!--- Put the file--->
<cfftp connection = "myConnection"
name = "myFile"
action = "PutFile"
localFile="#ftplocal#"
remoteFile="#ftpremote#"
failifexists="no"
passive = "Yes">
<p>Close the connection</p>
<cfftp action = "close"
connection = "myConnection"
stopOnError = "Yes">
<p>Did closing it succeed? <cfoutput>#cfftp.succeeded#</cfoutput>
<cfelse>
<p> <cfoutput>The file #ftplocal# does not exist.</cfoutput> </p>
</cfif>
Copy link to clipboard
Copied
Thanks for your message and help,
I checked spelling and word by word re type again just in case any invisible characters, the file exists when I use Windwos Explorer, but ColdFusion does not recognize, but cffile action upload can see the file to upload to file server.
Regards,
Iccsi,
Copy link to clipboard
Copied
What result did you get when you ran the latest code suggestion I gave you?
Copy link to clipboard
Copied
I got file does not exist message,
Regards,
Iccsi
Copy link to clipboard
Copied
Assume your file name is MyFile.txt. Also assume that the upload code is in the same directory as the FTP code.
Then, to upload the file to that directory, you could define the destination attribute as follows:
<cffile action="upload" destination="#expandpath('.')#" ...>
Then, in the above FTP code, use
<cfset ftplocal=expandPath('MyFile.txt')>
Copy link to clipboard
Copied
iccsi wrote
I got file does not exist message,
If the test fileExists says the file is not on the machine, then the file is not on the machine.
That is then the answer to your original question.
Copy link to clipboard
Copied
I use cfoutput to check the file name using CFFILE UPLOAD and see the file name change to localhost tmp folder,
Is it possible that the I need use CFFILE UPLOAD to the server and using FTP PutFile using the server temp file, if yes, are there any sample code to access this temp file for FTP PutFile.
Thanks again for helping,
\MyApp\runtime\work\Catalina\localhost\tmp\
Regards,
Copy link to clipboard
Copied
This is a discussion, isn't it? Could you please do us the courtesy of responding to the questions that members of the forum ask you?
Copy link to clipboard
Copied
iccsi wrote
I use cfoutput to check the file name using CFFILE UPLOAD and see the file name change to localhost tmp folder,
Is it possible that the I need use CFFILE UPLOAD to the server and using FTP PutFile using the server temp file, if yes, are there any sample code to access this temp file for FTP PutFile.
Thanks again for helping,
\MyApp\runtime\work\Catalina\localhost\tmp\
This question now makes me guess that you have 3 separate machines: your local Windows, the machine hosting ColdFusion and the FTP server. Is that so?
If so, then, yes, it might be a good idea to first upload the file from your local machine to the server hosting ColdFusion. What kind of machine is hosting ColdFusion: Linux or Windows?
Copy link to clipboard
Copied
Thanks amillion for helping,
Yes, there are 3 machines, client machine, ColdFusion Server and FTP server.
Yes, it works when I use CFFILE UPLOAD and then put File and works,
Thanks again for helping,
Regards,
Iccsi
Copy link to clipboard
Copied
If you look in your CF logs, you may see more detail on the error, which may help us help you.
But on the surface, shouldn't the first line of code have quotes around the URL? Without it, I wonder if either that line or the CFFTP line referring to it may be what are complaining. That's where knowing the real line in error and error message (hopefully in the CF log) would provide needed clarification.
Copy link to clipboard
Copied
Well spotted, Charlie Arehart​
I had missed that because of the error: "(The system cannot find the path specified)".
If ColdFusion had got that far, then the quotes would probably have been there. I am curious what iccsi​ has to say about this.
Copy link to clipboard
Copied
iccsi, you changed horses on us mid-stream, when you added the wrinkle of using cffile upload processing.
When you first wrote, the file you named was already on the server. And going back to that, I suspect I see now what was wrong with that (on rereading everything after a couple days off, for the Adobe cf summit east in DC this week).
In the very first code example, the filenwas in your user's folder. The reason cf says the file does not exist could be simply that the user running cf does not have permission to access that user folder.
Did you ever run that code bkbk sent, which added a fileexists check? You said in reply you got an error, but you didn't say where Was it on the filexists function? If so, perhaps cf fails (rather than the filexists check returning false) when the folder named is inaccessible to cf.
So, what user is running cf? If it's running as windows service, you can see that in the windows services page, or you can see it in the cf admin's "settings summary" page. If it's not the local "system" account, then perhaps that user does not have access to your own "users" folder.
Then, moving on to using cffile upload, you have never shown the code you implemented, especially where the upload destination was. Please show us that and tell us where you NOW get the error (with that code). It may still be a permissions issue, in that perhaps cf does not let the cffile UPLOAD WRITE to the named destination.
Copy link to clipboard
Copied
Thanks a million for the message,
The file is on My Document folder, so I do have access to the file and I can open the file using Windows Explorer.
I did use BKBK code and fileexist function return the file does not exist mesage,
BKBK is correct that there are 3 machines, client machine, ColdFusion Server and FTP server, so I use BKBK suggestion to use CFFILE UPLOAD and CFFTP PutFile then works,
Thanks again for helping,
Regards,
Iccsi