# ftp\_mkdir

**URL:** <https://forum.kirupa.com/t/ftp-mkdir/231584>\
**Category:** programming\
**Created:** [July 5, 2007, 10:27pm UTC](https://forum.kirupa.com/t/ftp-mkdir/231584 "2007-07-05T22:27:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patch](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/patch/32/1095_2.png) [@Patch](https://forum.kirupa.com/u/Patch)\
**Post date:** [July 5, 2007, 10:27pm UTC](https://forum.kirupa.com/t/ftp-mkdir/231584/1 "2007-07-05T22:27:00Z")

</div>

I found some code to create directories via ftp, but I can’t get it too work ☹

```php

// create directory through FTP connection 
function FtpMkdir($path, $newDir) { 
   
       $server='ftp.yourserver.com'; // ftp server 
       $connection = ftp_connect($ftp_server); // connection 
   
  
       // login to ftp server 
       $user = "me"; 
       $pass = "password"; 
       $result = ftp_login($connection, $user, $pass); 

   // check if connection was made 
     if ((!$connection) || (!$result)) { 
       return false; 
       exit(); 
       } else { 
         ftp_chdir($connection, $path); // go to destination dir 
       if(ftp_mkdir($connection,$newDir)) { // create directory 
           return $newDir; 
       } else { 
           return false;        
       } 
   ftp_close($conn_id); // close connection 
   } 

}  

```

got it from here: [http://www.kirupa.com/forum/showthread.php?t=70390&highlight=rmdir](http://www.kirupa.com/forum/showthread.php?t=70390&highlight=rmdir)

I’m not sure if i’m putting the right info in or if I’m defining $path and $newDir properly. Can any help me out or show me or something lol.

Cheers!
