如何将文件从本地文件夹复制到FTP服务器
问题描述:
我的本地驱动器上有一个文本文件,我想在FTP服务器上复制该文件,如果复制成功则该文件应该移动到另一个名为备份文件夹的文件夹,如果它无法复制的话文件应该移动到同一个驱动器上的错误文件夹,你能帮我解决这个问题吗?
我尝试过:
我试过了,但没办法。因为我只能将文件从本地驱动器复制到FTP服务器,但我无法备份复制文件,所以你能帮我吗
Hi, I have a text file on my local drive and I wanted to copy that file on FTP server, If it copied successfully then the file should move to the another folder called "Backup folder" and if it fails to copy then file should move to "Error Folder" on same drive, Can you help me to get out off this?
What I have tried:
I tried, but it didn't worked. As I am only able to copy file from local drive to FTP server, But I am not able to take backup of copied file, so could you help me
答
它取决于您使用哪个应用程序通过FTP上传文件。其中一些应用程序可以通过单个命令行调用编写脚本或支持上载。然后从批处理(Windows)或shell(Linux)脚本调用这样的脚本/命令行,检查返回值,并相应地采取行动(移动文件)。
对于 WinSCP ,有以下示例:自动将文件传输(或同步)到FTP服务器或SFTP服务器: :WinSCP [ ^ ]。请参阅最后一节检查脚本结果以获取示例批处理文件,您只需要通过move
替换 sendmail 调用>命令并使用相应的 WinSCP 脚本文件,如该页面所述。
It depends on which application you are using for uploading files via FTP. Some of those applications can be scripted or support uploads with a single command line call. Then call such a script / command line from a batch (Windows) or shell (Linux) script, check the return value, and act accordingly (move file).
For WinSCP this is well documented with examples: Automate file transfers (or synchronization) to FTP server or SFTP server :: WinSCP[^]. See there the last section Checking script results for an example batch file where you only have to replace the sendmail calls bymove
commands and use an appropriate WinSCP script file as described also on that page.