PHP ftp_fget() 函數(shù)
定義和用法
ftp_fget() 函數(shù)從 FTP 服務(wù)器上下載一個(gè)文件并保存到本地一個(gè)已經(jīng)打開的文件中。
若成功則返回 true,失敗則返回 false。
語法
ftp_fget(ftp_connection,local,remote,mode,resume)
參數(shù) | 描述 |
---|---|
ftp_connection | 必需。規(guī)定要使用的 FTP 連接(FTP 連接的標(biāo)識符)。 |
local | 必需。本地已經(jīng)打開的文件的句柄。 |
remote | 必需。規(guī)定從中進(jìn)行拷貝的文件的路徑。 |
mode |
必需。規(guī)定傳輸模式?赡艿闹涤校
|
resume | 必需。規(guī)定在遠(yuǎn)程文件中的何處開始拷貝。默認(rèn)是 0。 |
說明
參數(shù) resume 僅適用于 PHP 4.3.0 以上版本
例子
本例把文本從 "source.txt" 拷貝到 "target.txt" 中:
<?php
$source = "source.txt";
$target = fopen("target.txt", "w");
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
ftp_fget($conn,$target,$source,FTP_ASCII);
ftp_close($conn);
?>