• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
checking if a remote directory exists...

#1
[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);

#2
[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);
}

#3
[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!!!

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

#5
[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);
  
        }


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.