(PHP 4 >= 4.3.0, PHP 5, PHP 7)
ftp_nb_fget — �� FTP ��������ȡ�ļ���д�뵽һ�����ļ�����������
$ftp_stream
, resource $handle
, string $remote_file
[, int $mode = FTP_IMAGE
[, int $resumepos = 0
]] ) : intftp_nb_fget() ��Զ�� FTP ��������ȡһ���ļ�
�������� ftp_fget() ������������ ���������첽��ʽ��ȡ�ļ��ģ� �����������ļ��Ĺ�������ij�����ִ������������
ftp_streamFTP ���ӱ�ʾ����
handle�����洢���ݵ�һ���Ѿ����ļ������
remote_fileԶ���ļ�·����
mode
����ģʽ�������� FTP_ASCII ����
FTP_BINARY��
resumeposԶ���ļ���ʼ���ص�λ�ã�����Զ���ļ����ĸ��ֽڿ�ʼ���أ���
���� FTP_FAILED �� FTP_FINISHED
�� FTP_MOREDATA��
| �汾 | ˵�� |
|---|---|
| 7.3.0 |
���� mode ��Ϊ��ѡ������
��֮ǰ�İ汾�У�����һ�����������
|
Example #1 ftp_nb_fget() ��������
<?php
// ��Ҫд����ļ�
$file = 'index.php';
$fp = fopen($file, 'w');
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// ��ʼ������
$ret = ftp_nb_fget($conn_id, $fp, $file, FTP_BINARY);
while ($ret == FTP_MOREDATA) {
// ����Ҫ���Ĺ���
echo ".";
// ��������...
$ret = ftp_nb_continue($conn_id);
}
if ($ret != FTP_FINISHED) {
echo "There was an error downloading the file...";
exit(1);
}
// �ر��ļ����
fclose($fp);
?>