Ftp:upload(file, [remote_name])


Upload a file to the connected FTP server.

Parameters

file

A string or a File object representing the file to be uploaded to the server.

[remote_name]

An optional string that contains the destination path and filename on the server.
If not provided, the file will be uploaded on the current FTP directory (See Ftp.currentdir) using the same filename.

Return value


Returns true if uploading to the FTP server was successful, or false otherwise.
This method return a Task instance. Once the Task has finished, it will return a boolean value indicating if the operation was successful.

Example

local net = require "net" -- connect to the FTP server local url = "your ftp server" local client = net.Ftp(url, "username", "password") -- upload file "test.txt" if await(client:upload(File("test.txt"))) then print("Successfully uploaded 'test.txt' to "..url) else error(net.error) end