Guest User

Untitled

a guest
Jun 7th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1.    function FtpMkdir($path, $newDir) {
  2.        $path = 'mainwebsite_html/'.$path;
  3.        $server='ftp.myserver.com'; // ftp server
  4.        $connection = ftp_connect($server); // connection
  5.  
  6.  
  7.        // login to ftp server
  8.        $user = "user@myserver.com";
  9.        $pass = "password";
  10.        $result = ftp_login($connection, $user, $pass);
  11.  
  12.        // check if connection was made
  13.        if ((!$connection) || (!$result)) {
  14.           return false;
  15.           exit();
  16.        } else {
  17.          ftp_chdir($connection, $path); // go to destination dir
  18.          if(ftp_mkdir($connection, $newDir)) { // create directory
  19.              ftp_site($connection, "CHMOD 777 $newDir") or die("FTP SITE CMD failed.");
  20.              return $newDir;
  21.          } else {
  22.            return false;
  23.          }
  24.  
  25.          ftp_close($connection); // close connection
  26.       }
  27.  
  28.   }
Add Comment
Please, Sign In to add comment