Ftp Upload Via Web Form In Codeigniter

Wednesday, November 12, 2008

Just recently i've managed to use Codeigniter's FTP class to upload file from my admin page,using web form that is, the concept is easy
first,took the file path using Codeigniter's Upload Class (Ftp Class won't get the full path)
second,upload it using FTP (code igniter also have its own Ftp Class)


in order to do so ,i've modified my upload class ,so that it will upload uisng ftp instead of moving file
here's the line of interest


if ( !$CI->ftp->upload($this->file_temp, $this->upload_path.$this->file_name))
{
$this->set_error('upload_destination_error');
return FALSE;
}
$CI->ftp->close();


don't forget to load the ftp library n get it connected like this

$CI =& get_instance();
$CI->load->library('ftp');
if( $CI->ftp->connect())

n thats it,now you can use Codeigniter's Ftp class to upload file from a web form :D

0 comments:

  © Blogger template Newspaper by Ourblogtemplates.com 2008

Back to TOP