Read file txt on ftp server - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Read file txt on ftp server (/showthread.php?tid=39135) |
Read file txt on ftp server - El Forum - 03-02-2011 [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 Read file txt on ftp server - El Forum - 03-02-2011 [eluser]InsiteFX[/eluser] Your Constructor is wrong! Code: // function Cmsftp() should be this! And make sure you change your Model to CI_Model InsiteFX Read file txt on ftp server - El Forum - 03-02-2011 [eluser]Unknown[/eluser] I don't need model that why I put break code there, as I only collect file from FTP server then I open i web, but my issue is I unable to open those file in ftp server via web, may you share with me how to open some file with parse_file into it? |