Uploading, renaming, and deleting files and directories

ftp->put_file("localfile", "remotefile");

std::string reply=ftp->put_unique_file("localfile");

ftp->append_file("localfile", "remotefile");

std::vector<char> buffer;

ftp->put("remotefile", buffer.begin(), buffer.end());

ftp->append("remotefile", buffer.begin(), buffer.end());

std::string reply=ftp->put_unique(buffer.begin(), buffer.end());

put_file() uploads a local file to the server, with an explicit file name on the server. put_unique_file() uploads a local file to the server, with the server creating a unique name for the new file. put_unique_file() returns the response from the server that should indicate the created file's name; however FTP does not specify the message's exact format. append_file() is a lesser-used function to append the uploaded file's contents to the existing file.

put(), put_unique(), and append() specify the uploaded file's contents by a beginning and an ending iterator value, instead of a filename. The iterators should be random access iterators, but input iterators are also acceptable. Input iterators cannot be used when the server requires the ALLO command to precede the file transfer. With forward/bidirectional iterators the sequence gets iterated over twice, internally; once to compute the upload size for the ALLO, and the second time to effect the transfer. All these functions also take the following optional parameters.

  1. Binary transfer flag. The default value of true effects binary mode file transfer; false effects text mode file transfer. The text mode transfer makes no changes to the transferred contents. This specifies the mode setting for the transfer, and the transferred data gets sent to the server, as is.

  2. x::fdtimeoutconfig that sets up the timeout configuration for the data channel used to transfer the requested file.

ftp->mkdir("directory");
ftp->rmdir("directory");
ftp->unlink("filename");
ftp->rename("from", "to");

Self-explanatory.