Search code examples
phpftpfat-free-framework

F3 - How to connect to FTP on Fat Free Framework?


Does there exist a class in F3 that allow me work with an FTP? I need upload from a web form, and then download from a web page. I need to work with personal documents, and therefore I can't upload it to public folder.


Solution

  • As Far as I know, F3 has no FTP Class to use. The code below is a work around.

    1. Download this Library: Nicolab/php-ftp-client

    2. Copy the three files in /src/FtpClient/ into a folder named ftpclient and then add the folder to your autoload.

    3. Connect!

      $ftp = new \FtpClient\FtpClient();
      $ftp->connect($host);
      $ftp->login($login, $password);
      
    4. Store the connection in your HIVE

      $f3->set('FTP', $ftp);
      //Now you can do : https://github.com/Nicolab/php-ftp-client#usage
      //Also extend https://github.com/Nicolab/php-ftp-client#extend