KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Moving files on an FTP server with 4D Internet Commands
PRODUCT: 4D Internet Commands | VERSION: 2004 | PLATFORM: Mac & Win
Published On: March 14, 2007
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Trying to move files from one directory to another is not as intuitive as other actions done on an FTP server. One would expect a move command, but unfortunately the protocol does not support such a command. To move a file from one directory to another on an FTP server, the 4D Internet Commands (4DIC) function FTP_Rename will need to be used. The example below connects to an FTP server, creates a new folder called "newfolder", and moves the existing file "test.txt" into the new folder:


` ------------------------------------------------------------
C_LONGINT($errcode;$ftpID)

$errcode:=FTP_Login ("hostftpserver";"user";"password";$ftpID;"Hello")
$errcode:=FTP_MakeDir ($ftpID;"newfolder")
$errcode:=FTP_Rename ($ftpID;"test.txt";"\newfolder/test.txt")
$errcode:=FTP_Logout ($ftpID)
` ------------------------------------------------------------




Please note that no error checking is performed in the above example, to aid in readability. You should be sure to check the result of all 4DIC commands.