Lua
Lua
Move File to Another Directory on Server
See more FTP Examples
Moves a file from one directory to another. This is accomplished by renaming the file using a filepath that includes the directory.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local ftp = chilkat.Ftp2.new()
ftp.hostname = "ftp.example.com"
ftp.username = "login"
ftp.password = "password"
-- Connect and login to the FTP server.
local success = ftp:connect()
if not success then
print(ftp.last_error_text)
return
end
-- Rename the remote file (or directory)
local existingFilepath = "dirA/hello.txt"
local newFilepath = "dirB/hello.txt"
success = ftp:rename_remote_file(existingFilepath, newFilepath)
if not success then
print(ftp.last_error_text)
return
end
success = ftp:disconnect()