mput
将文件或文件夹上传到 SFTP 或 FTP 服务器
说明
示例
上传文件
连接到 FTP 服务器并将文件从本地机器上传到该服务器。此示例显示 ftp.example.com
(实际上并不存在的计算机)上的一个假想 FTP 会话。如果您拥有 FTP 服务器帐户,有权向该服务器上传文件,则可以像本例中一样使用 mput
函数。
首先,连接到服务器。
s = ftp('ftp.example.com')
FTP with properties: Host: "ftp.example.com" Username: "anonymous" Port: 21 ServerLocale: "en_GB" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
显示 FTP 服务器上当前文件夹的内容。
dir(s)
myscript.m README.txt pub
从本地机器上传文件到 FTP 服务器。
mput(s,'myNewScript.m');
在 FTP 服务器上显示更新后的内容,包括新的 myNewScript.m
文件。
dir(s)
myscript.m myNewScript.m README.txt pub
上传多个文件。如果文件名中有部分文字相同,则可以使用通配符 (*
) 来匹配其余名称。在本例中,使用通配符匹配本地机器上的文件名 image001.png
、image002.png
和 image003.png
。
mput(s,'image*png');
在 FTP 服务器上显示更新后的内容。
dir(s)
image001.png image002.png image003.png myscript.m myNewScript.m README.txt pub
输入参数
s
— 连接到 SFTP 或 FTP 服务器
SFTP 对象 | FTP 对象
与 SFTP 或 FTP 服务器的连接,指定为 SFTP 对象或 FTP 对象。
contents
— 本地文件或文件夹
字符向量 | 字符串标量
本地文件或文件夹,指定为字符向量或字符串标量。
要匹配本地机器上的多个文件或文件夹,可以在 contents
中包含通配符 (*
)。例如,如果您将 contents
指定为 *.docx
,则 mput
会上传名称以 .docx
结尾的所有文件。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)