public function upload_attachment() {
//validation start
$config['upload_path'] = './uploads';
$config['allowed_types'] = 'jpg|png|gif';
$config['max_width'] = 1024;
$config['max_height'] = 768;
$config['max_size'] = 1000;
//validation end
$this->load->library('upload', $config);
if (!$this->upload->do_upload('attachment')) {
echo 'Erorr :' . $this->upload->display_errors();
} else {
$attachment = $this->upload->data();
echo $attachment['file_name'];
}
}