欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-03-18 12:27:54
...
  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. ?>
复制代码