mput

Upload files to an FTP server.

Attention: Available only with Twin Activate commercial edition.

Syntax

[R, msg, filelist] = mput(ftpObj, filename)

[R, msg, filelist] = mput(ftpObj, dirname, 'recursive', recursiveFlag)

Inputs

ftpObj
FTP object
Type: FTP object
filename
Local file to upload. Relative path to the file may also be used. The filename can contain wildcards.
Type: string
dirname
Directory to upload.
Type: string
recursiveFlag
If 'true' then all sub-directories of the given dirname are uploaded recursively. The file/directory structure of the remote location is replicated on the server.
Type: scalar

Outputs

R
Returns 0 if successful; returns 1 if not successful.
msg
Returns an error message if the command is not succcessful.
filelist
List of uploaded files.

Examples

Upload a single file on the server:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Upload 'local_file1.txt'
mput(ftpObj,'local_file1.txt');
% Check that the file is uploaded on the server
disp('Contents of the remote root directory:')
dir(ftpObj)
close(ftpObj);
Contents of the remote root directory:
ans = -rw-rw-rw-   1 owner    group           0 Feb 20 10:41 local_file1.txt
Upload multiple files using a wildcard:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Upload multiple files using a wildcard
[R, msg, filelist] = mput(ftpObj,'*.txt');
disp('List of uploaded files:')
filelist
% Check that the file is uploaded on the server
disp('Contents of the remote root directory:')
dir(ftpObj)
close(ftpObj);
List of uploaded files:
filelist = 
{
  [1,1] local_file1.txt
  [2,1] local_file2.txt
}
Contents of the remote root directory:
ans = -rw-rw-rw-   1 owner    group           0 Feb 20 10:41 local_file1.txt
-rw-rw-rw-   1 owner    group           0 Feb 20 10:41 local_file2.txt
Upload a directory recursively:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Upload 'LocalFolder' recursively
[R, msg, filelist] = mput(ftpObj,'LocalFolder','recursive', true);
disp('List of uploaded files:')
filelist
% Check that the file is uploaded on the server
disp('Contents of the remote root directory:')
dir(ftpObj)
close(ftpObj);
List of uploaded files:
filelist = 
{
  [1,1] file2_1.txt
  [1,2] file2_2.txt
  [1,3] LocalFolder2/file1.txt
}
Contents of the remote root directory:
ans = drwxrwxrwx   1 owner    group           0 Feb 20 10:42 LocalFolder2
-rw-rw-rw-   1 owner    group           0 Feb 20 10:42 file2_1.txt
-rw-rw-rw-   1 owner    group           0 Feb 20 10:42 file2_2.txt