0

用php脚本ftp上传文件


FTP脚本上传个文件,如果目标机器已经有,就提示已经存在,并且显示文件大小,
如果没有这个文件就上传,很久没有摆弄php,顺手写了一个

  1. #!/usr/bin/php -q
  2. <?php
  3. $IP = 'baiqiuyi.com';
  4. $NAME = '姓名';
  5. $PASSWD = '密码';
  6. $file = '文件名称';
  7. $fp = fopen($file, 'r');
  8. $ID = ftp_connect($IP);
  9. $RE = ftp_login($ID, $NAME, $PASSWD);
  10. $res = ftp_size($ID, $file);
  11. if ($res != -1) {
  12.        echo "文件 $file 已存在 , 大小为$res 字节 !\n";
  13. } else {
  14.        (ftp_fput($ID, $file, $fp, FTP_ASCII));
  15.        echo "文件 $file 上传完毕!\n";
  16. }
  17. ftp_close($ID);
  18. ?>

我猜~这些文章你可能也感兴趣

暂时没有留言..

给我留言:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word