This project has moved. For the latest updates, please go here.

Implement MoveFile


Currently throws a NotImplemented Exception


smurfiv wrote Mar 13, 2012 at 8:45 PM

The FTP protocol is not capable of moving files on the FTP server. It was merely designed with file transfer in mind, but there is a simple trick that most FTP servers accept for moving a file: renaming. Let us look ats an example:


Note that this trick does not work for every FTP server. It usually works for Unix/Linux FTP servers only. If your server does not support it you can also do it downloading the file, removing it from its original remote directory and upload it again to its destination directory. It's a very slow way to move a remote file but at least works in every FTP server:

smurfiv wrote Mar 13, 2012 at 8:46 PM

You want to make sure you check the existence of the new name before renaming files, because otherwise you could risk losing files. Just do a simple check with ftp_size with the new name. If it's !=-1, you're going to want to throw some kind of error, otherwise you'll be losing a file...

wrote Feb 13, 2013 at 7:53 PM