Login   Register  
PHP Classes
elePHPant
Icontem

File: nfFTP_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of ben bi  >  nfFTP  >  nfFTP_test.php  >  Download  
File: nfFTP_test.php
Role: Example script
Content type: text/plain
Description: example file
Class: nfFTP
Manipulate files and directories in FTP servers
Author: By
Last change: update
Date: 2009-03-25 04:02
Size: 2,857 bytes
 

Contents

Class file image Download
<?php

/**
* nfFTP test
*
* @version     nfFTP_test.php, v0.1,  2009-01-08 18:13:06
* @package    net
*/
error_reporting(E_ERROR E_PARSE );
require_once(
"nfFTP.class.php");

// remote source ftp server parameters
$remoteSrcServerParams = array(
       
'host'=>'192.168.0.101',
       
'port'=>'21',
       
'user'=>'user',
       
'password'=>'password',
       
'transferMode'=> FTP_BINARY,          //FTP_BINARY or FTP_ASCII
       
'dataDirectory'=>'remote_images_src/'
);

// remote destination ftp server parameters
$remoteDstServerParams = array(
       
'host'=>'192.168.0.101',
       
'port'=>'21',
       
'user'=>'user',
       
'password'=>'password',
       
'transferMode'=> FTP_BINARY,          //FTP_BINARY or FTP_ASCII
       
'dataDirectory'=>'remote_images_dst/'
);
/**************************************  parameters for test, end  *******************************/

$localServerParams = array(
       
'mainPath' => realpath(dirname(__FILE__)).'/',
       
'downloadDirectory'=>'download/'
);


$nfFTP = new nfFTP;
//$action = 'download';
//$action = 'upload';
$action 'deltree';

/**************** folder and files download example  *****************/
if($action == 'download')
{
    
$nfFTP->host $remoteSrcServerParams['host'];
    
$nfFTP->port $remoteSrcServerParams['port'];
    
$nfFTP->user $remoteSrcServerParams['user'];
    
$nfFTP->password $remoteSrcServerParams['password'];
    
$nfFTP->transferMode $remoteSrcServerParams['transferMode'];

    
chdir($localServerParams['mainPath'].$localServerParams['downloadDirectory']);
    
$nfFTP->login();
    
$nfFTP->nGet($remoteSrcServerParams['dataDirectory'], FTP_BINARY);
    
$nfFTP->close();
}
/**************** folder and files upload example  *****************/
elseif($action == 'upload')
{
    
$nfFTP->host $remoteDstServerParams['host'];
    
$nfFTP->port $remoteDstServerParams['port'];
    
$nfFTP->user $remoteDstServerParams['user'];
    
$nfFTP->password $remoteDstServerParams['password'];
    
$nfFTP->transferMode $remoteDstServerParams['transferMode'];

    
$nfFTP->login();
    
$nfFTP->changeDir($remoteDstServerParams['dataDirectory']);
    
$nfFTP->nPut($localServerParams['mainPath'].$localServerParams['downloadDirectory'], FTP_BINARY);
    
$nfFTP->close();
}
/**************** folder and files deltree example  *****************/
elseif($action == 'deltree')
{
    
$nfFTP->host $remoteDstServerParams['host'];
    
$nfFTP->port $remoteDstServerParams['port'];
    
$nfFTP->user $remoteDstServerParams['user'];
    
$nfFTP->password $remoteDstServerParams['password'];
    
$nfFTP->transferMode $remoteDstServerParams['transferMode'];

    
$nfFTP->login();
    
$nfFTP->deltree($remoteDstServerParams['dataDirectory'], true);
    
$nfFTP->close();
}



echo 
'done.';

?>