php ftp上传,下载,删除服务器文件实例 |
时间:2015-01-23 来源:西部数据 作者:西部数据 |
|
php ftp上传,下载,删除服务器文件实例.
php ftp传送文件到服务器,实例代码如下:
- <?php
-
- $ret = ftp_nb_get ($my_connection, "test", "README", FTP_BINARY,
- filesize("test"));
-
-
- while ($ret == FTP_MOREDATA) {
-
-
- echo ".";
-
- $ret = ftp_nb_continue ($my_connection);
- }
- if ($ret != FTP_FINISHED) {
- echo "下载出错...";
- exit(1);
- }
- ?>
php ftp删除文件,实例代码如下:
- <?php
- $file = 'public_html/old.txt';
-
- $conn_id = ftp_connect('www.phpfensi.com');
-
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
-
- if (ftp_delete($conn_id, $file)) {
- echo "$file 文件删除成功 n";
- } else {
- echo "删除 $file 文件失败n";
- }
-
- ftp_close($conn_id);
- ?>
php ftp下载文件,实例代码如下:
- <?php
- $file = 'somefile.txt';
-
- $conn_id = ftp_connect($ftp_server);
-
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
-
- $res = ftp_size($conn_id, $file);
- if ($res != -1) {
- echo " $file 文件大小为 $res字节";
- } else {
- echo "获取远程文件大小失败";
- }
-
- ftp_close($conn_id);
- ?>
|
|
|
|