CodeIgniter Forums
checking if a remote directory exists... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: checking if a remote directory exists... (/showthread.php?tid=24101)



checking if a remote directory exists... - El Forum - 10-30-2009

[eluser]visormatt[/eluser]
So I am building a client back-end for my company and I have hit a block... I am using CI's FTP to create folders and subfolders based off of some form details... Now what i need to do is check if the Client Directory Exists via FTP before adding the folders... Any help would be appreciated.



$this->ftp->connect(); // NOW CREATE THE FOLDER STRUCTURE ON THE SERVER

if(!$absolutePath .$_POST['upClient']) // check if Client directory exists if not CREATE IT
{
$this->ftp->mkdir($absolutePath .$_POST['upClient'], DIR_WRITE_MODE);
}

$this->ftp->mkdir($absolutePath .$_POST['upClient'] ."/" .$_POST['upNumber'], DIR_WRITE_MODE);
$this->ftp->mkdir($absolutePath .$_POST['upClient'] ."/" .$_POST['upNumber'] ."/swf", DIR_WRITE_MODE);
$this->ftp->mkdir($absolutePath .$_POST['upClient'] ."/" .$_POST['upNumber'] ."/img", DIR_WRITE_MODE);

$this->ftp->close(); // BEST PRACTICE - Close the connection...

redirect('development/selectedProject/' .$upNumber);


checking if a remote directory exists... - El Forum - 10-30-2009

[eluser]bretticus[/eluser]
Code:
if($this->ftp->list_files($absolutePath . $_POST[‘upClient’]) === FALSE) // check if Client directory exists if not CREATE IT
{
  $this->ftp->mkdir($absolutePath .$_POST[‘upClient’], DIR_WRITE_MODE);
}



checking if a remote directory exists... - El Forum - 10-30-2009

[eluser]visormatt[/eluser]
YOU DA MAN!!!!

Thanks a bunch... I was looking in the same direction but you have saved me a headache.. MUCH APPRECIATED, works perfect!!!


checking if a remote directory exists... - El Forum - 03-24-2011

[eluser]chamil sanjeewa[/eluser]
thank you very much


checking if a remote directory exists... - El Forum - 04-06-2011

[eluser]chamil sanjeewa[/eluser]
I havu use your codes early but I had a problem with it.
the below one works fine
Code:
if (count($this->ftp->list_files($this->image_path)) == 0) { // check if Client directory exists if not CREATE IT
            $this->ftp->mkdir('foldername/foldername/foldername', DIR_WRITE_MODE);
  
        }