[eluser]Unknown[/eluser]
Hi,
nowadays I try to start my project to read txt file from FTP server then generated into table, this is my code
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Cmsftp extends CI_Controller{
private $limit = 5;
function Cmsftp(){
parent::__construct();
// load library
$this->load->library(array('table','ftp'));
//$this->load->model('model_bizunit','',TRUE);
}
function index($offset = 0) {
$uri_segment = 3;
$offset = $this->uri->segment($uri_segment);
//$cmsftps = $this->ftp->list_files->('/');//get_paged_list($this->limit, $offset)->result();
// generate pagination
$this->load->library('pagination');
$this->load->library('ftp');
$config['base_url'] = site_url('/');
$config['total_rows'] = $this->ftp->list_files('/');
//$config['total_rows'] = $this->model_bizunit->count_all();
$config['per_page'] = $this->limit;
$config['uri_segment'] = $uri_segment;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
// Load file into table
$this->load->library('table','ftp');
$config['hostname'] = 'localhost';
$config['username'] = 'viewuser';
$config['password'] = 'viewuser';
$config['port'] = 21;
$config['passive'] = FALSE;
$config['debug'] = TRUE;
$this->ftp->connect($config);
$this->table->set_empty(" ");
$this->table->set_heading('FileName / Directory','Action');
$cmsftps = $this->ftp->list_files('/affinium/Affinium/Campaign/partitions/partition1/list_processed/SMS/COMMON/');
//$cmsftps = $this->ftp->list_files('/');
$i = 0 + $offset;
foreach ($cmsftps as $row) {
$this->table->add_row($row,
anchor('cmsftp/view'.$row,'view',array('class'=>'view')).' '.
anchor($row,'update',array('class'=>'update')).' '.
anchor($row,'delete',array('class'=>'delete')));
}
$data['table'] = $this->table->generate();
$this->load->view('v_cmsftp', $data);
$this->ftp->close();
}
function view($row){
// set common properties
$this->load->library('Csvreader');
$data['title'] = 'File Details';
$data['link_back'] = anchor('cmsftp/index/','Back to list of File',array('class'=>'back'));
// get person details
$filePath = $row;
$data['csvData'] = $this->csvreader->parse_file($filePath);
foreach ($data as $rowq) {
$this->table->add_row($rowq);
}
$data['table'] = $this->table->generate();
$this->load->view('v_cmsftpview', $data);
}
}
?>
but issue now when I try to generated txt file into table, I can't ? Appreciated to every one who may share your knowledge to fix my code
Thanks,
Bayu