Ness PHP FTP Class
Required Namespace
  • Ness
    • Tool
      • FTP

You can include this library to your code file by typing the below code;

use Ness\Tool\FTP


About FTP Class #top

You can use Ness framework's ftp class to connect ftp servers.


Available Methods #top

Initialize
$myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
Initialize ftp class
Return Object
Parameters $host String; FTP Host
$user String; User Account
$password String; Password
$port Integer; Port
$timeout Integer; connection time out, default 100



Connect
                                
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
                            
                            
Connect ftp class
Return Boolean
Parameters None



Close
                                
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
        //Ftp action1
        //Ftp action2
        //Ftp action3
    $myftp->Close();


                            
                            
Close a ftp connection
Return Void
Parameters None



Error
                                    
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
        //Ftp action1
    echo $myftp->Error();
        //Ftp action2
    echo $myftp->Error();
        //Ftp action3
    echo $myftp->Error();
    $myftp->Close();
    
    
                                
                            
Return last Error
Return String
Parameters None



Download
                                    
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->Download("C:\downloads\readme.txt", public_html\w\read_.txt);
    $myftp->Close();
    
    
                                
                            
Download a file from ftp server.
Return Boolean
Parameters $param1 String; Local directory for file
$parm2 String; Remote firectory of file



Upload
                                    
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->Upload("public_html\w\read_.txt","C:\downloads\readme.txt");
    $myftp->Close();
        
        
                                
                                
Upload a file to ftp server.
Return Boolean
Parameters $param1 String; Remote firectory of file Local directory for file
$parm2 String; Local directory for file



Rename
                                    
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->Rename("public_html\w\read_.txt","public_html\w\readme_file_renamed.txt");
    $myftp->Close();
        
        
                                
                                
Rename a file.
Return Boolean
Parameters $param1 String; Directory with old file name
$parm2 String; Directory with new file name



DeleteFile
                                    
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->Delete("public_html\w\read_.txt");
    $myftp->Close();
        
        
                                
                                
Delete a file.
Return Boolean
Parameters $param1 String; Directory with file name



FileSize
                                    
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    echo $myftp->FileSize("public_html\w\read_.txt");
    $myftp->Close();
        
        
                                
                                
Size of file.
Return Float
Parameters $param1 String; Directory with file name



DeleteDirectory
                                        
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->DeleteDirectory("public_html\web_app");
    $myftp->Close();
        
        
                                    
                                
Delete a directory
Return Boolean
Parameters $param1 String; Directory name



DirectoryList
                                        
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    var_dump( $myftp->DirectoryList("public_html\web_app")); 
    $myftp->Close();
        
        
                                    
                                
Directory Listing
Return Array
Parameters $param1 String; Directory name



CreateDirectory
                                        
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->CreateDirectory("public_html\web_app\updated");
    $myftp->Close();
            
            
                                    
                                    
Create a new directory on ftp server.
Return Boolean
Parameters $param1 String; New directory name



SetPermission
                                        
    $myftp = new Ness\Tool\FTP($host,$user,$password, $port= 21, $timeout);
    $myftp->Connect();
    $myftp->SetPermission("public_html\web_app\test.html", 747);
    $myftp->Close();
            
            
                                    
                                    
Change permission for file.
Return Boolean
Parameters $param1 String; Directory/File name
$param2 Integer; Permission