PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<ftp_fgetftp_get_option>
Last updated: Mon, 16 Jul 2012

ftp_fput

(PHP 3 >= 3.0.13, PHP 4, PHP 5)

ftp_fput -- 上传一个已经打开的文件到 FTP 服务器

说明

bool ftp_fput ( resource ftp_stream, string remote_file, resource handle, int mode [, int startpos] )

ftp_fput() 函数用来上传一个在已经打开的文件中的数据到 FTP 服务器,参数 handle 为所打开文件的句柄。参数 remote_file 为上传到服务器上的文件名。传输模式参数 mode 只能为 (文本模式) FTP_ASCII 或 (二进制模式) FTP_BINARY 其中的一个。

例子 1. ftp_fput() example

<?php

// open some file for reading
$file = 'somefile.txt';
$fp = fopen($file, 'r');

// connect to the server
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// try to upload the file
if(ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
   echo
"Successfully uploaded $file\n";
} else {
   echo
"There was a problem while uploading $file\n";
}

// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);

?>

注: 参数 startpos 只适用于 4.3.0 以上版本。

如果成功则返回 TRUE,失败则返回 FALSE

参见 ftp_put()ftp_nb_fput()ftp_nb_put()




<ftp_fgetftp_get_option>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST