当前位置:Gxlcms > PHP教程 > php使用ftp函数创建目录(生成静态)

php使用ftp函数创建目录(生成静态)

时间:2021-07-01 10:21:17 帮助过:9人阅读

  1. /**

  2. * desc:create directory through FTP connection
  3. * link:bbs.it-home.org
  4. * date:2013/02/24
  5. */
  6. function FtpMkdir($path, $newDir) {
  7. $server='ftp.yourserver.com'; // ftp server
  8. $connection = ftp_connect($server); // connection
  9. // login to ftp server
  10. $user = "me";
  11. $pass = "password";
  12. $result = ftp_login($connection, $user, $pass);
  13. // check if connection was made
  14. if ((!$connection) || (!$result)) {
  15. return false;
  16. exit();
  17. } else {
  18. ftp_chdir($connection, $path); // go to destination dir
  19. if(ftp_mkdir($connection,$newDir)) { // create directory
  20. return $newDir;
  21. } else {
  22. return false;
  23. }
  24. ftp_close($conn_id); // close connection
  25. }
  26. }
  27. ?>

人气教程排行