binary
将 FTP 传输模式设置为二进制
说明
示例
将传输模式设置为二进制
使用 ASCII 传输模式从 FTP 服务器下载文本文件。下载文件后,将传输模式设置回二进制。
首先,连接到美国国家环境信息中心 (NCEI) 的 FTP 服务器。
ftpobj = ftp('ftp.ngdc.noaa.gov')
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
默认传输模式为二进制。下载文本文件时,您可以改用 ASCII 模式,以便换行符能够正确转换。
将传输模式设置为 ASCII。要显示当前传输模式,请显示 FTP 对象。
ascii(ftpobj) ftpobj
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "ascii" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
下载文本文件。
mget(ftpobj,'README.txt');
ASCII 传输模式仅用于文本文件。要下载非文本文件(如图像或 ZIP 存档),请使用二进制传输模式。
将传输模式设置回二进制。要检查模式现在是否为二进制,请再次显示 FTP 对象。
binary(ftpobj) ftpobj
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/"
FTP 服务由美国国家环境信息中心 (NCEI) 提供。有关 NCEI 服务条款,请参阅 NCEI 隐私政策、免责声明和版权。
输入参数
ftpobj
— FTP 服务器连接
FTP 对象
FTP 服务器连接,指定为 FTP 对象。
版本历史记录
在 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)