title: FTP Mirroring in Codeigniter
body: <p>We maintain over 70 property websites on a single CI application fueled by a database (actually, one database and application for production sites and one database and application for development sites) to provide the necessary differences for each site. We provide a custom CMS so that the property managers can update their site regularly. There is an approval process to push changes made to their development site through the CMS to their production site.</p>
  
  <p>One CMS function is to upload photo albums. Once the album is uploaded on development and approved for production, I need to copy this folder from the development assets to their production assets.</p>
  
  <p>I establish the FTP connection and create the photo album folder without issue using:</p>
  
  <pre><code>$this-&gt;ftp-&gt;mkdir($path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/', DIR_WRITE_MODE);
  </code></pre>
  
  <p>($path[‘ftpP’] looks like this: /httpdocs/edrAssets/propsP/700/</p>
  
  <p>When I try to use the mirror function in the FTP class, I don’t get any errors or warnings but I also don’t get any transfer—- just nothing.</p>
  
  <p>Here is that code:</p>
  
  <pre><code>$dLink = $path['ftpD'].'photoAlbums/'.$album[0]['albumFolderName'].'/';
  $pLink = $path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/';
  
  $this-&gt;ftp-&gt;mirror($dLink, $pLink); 
  </code></pre>
  
  <p>I have been fighting this since late Thursday night and need some advice. ALL help is appreciated.</p>
  
  <p>Jon</p>
  
  <p>REQUESTED LOG FILE:</p>
  
  <p>DEBUG - 2012-06-18 07:15:31 --> Controller Class Initialized</p>
  
  <p>DEBUG - 2012-06-18 07:15:31 --> Ftp class already loaded. Second attempt ignored.</p>
  
  <p>DEBUG - 2012-06-18 07:15:31 --> Trying to FTP here</p>
  
  <p>ERROR - 2012-06-18 07:15:31 --> Severity: Warning  --> opendir() [function.opendir]: Unable to access /httpdocs/edrAssets/propsD/700/photoAlbums/theUSOpen2012/ /var/www/vhosts/edrpropertyoperations.com/httpdocs/WEBdev/system/libraries/Ftp.php 532</p>
  
  <p>ERROR - 2012-06-18 07:15:31 --> Severity: Warning  --> opendir(/httpdocs/edrAssets/propsD/700/photoAlbums/theUSOpen2012/) [function.opendir]: failed to open dir: No such file or directory /var/www/vhosts/edrpropertyoperations.com/httpdocs/WEBdev/system/libraries/Ftp.php 532</p>
  
  <p>DEBUG - 2012-06-18 07:15:31 --> Final output sent to browser</p>
  
  <p>DEBUG - 2012-06-18 07:15:31 --> Total execution time: 0.1626</p>
  
  <p><em><strong></em></strong> ADDED <strong><em>*</em></strong></p>
  
  <pre><code>    public function approved_create_album( $id ){   
           $thisTask = $this-&gt;mcms-&gt;getSingleAdminTask( $id );
  
           $album = $this-&gt;mcms-&gt;getAlbumByID($thisTask[0]['itemID']);    
           $path = $this-&gt;mcms-&gt;path_variables( $album[0]['propNumber']);
  
           $this-&gt;load-&gt;library('ftp');   
           $ftp['hostname'] = &lt;REMOVED&gt;;
           $ftp['username'] = &lt;REMOVED&gt;;  
           $ftp['password'] = &lt;REMOVED&gt;;
           $ftp['port']     = 21;     
           $ftp['passive']  = FALSE;  
           $ftp['debug']    = TRUE;   
           $ftp['ssl_mode'] = FALSE;  
           $this-&gt;ftp-&gt;connect($ftp);
  
           $dLink = $path['ftpD'].'photoAlbums/'.$album[0]['albumFolderName'].'/';    
           $pLink = $path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/';
  
           if( !file_exists($pLink) &amp;&amp; !is_dir($pLink)){
                $this-&gt;ftp-&gt;mkdir($path['ftpP'].'photoAlbums/'.$album[0]['albumFolderName'].'/', DIR_WRITE_MODE);     
           } // end if
  
           log_message('debug', 'Trying to FTP here');
           $this-&gt;ftp-&gt;mirror($dLink, $pLink);
  
           echo $dLink . " to " . $pLink; 
  } // end approved_create_album function
  </code></pre>