Home > Backend Development > PHP Tutorial > PHP uses ftp function to create directory (generate static)

PHP uses ftp function to create directory (generate static)

WBOY
Release: 2016-07-25 09:04:40
Original
1369 people have browsed it
  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. ?>

复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template