Skip to content

Instantly share code, notes, and snippets.

@collinsb
Created May 28, 2015 20:36
Show Gist options
  • Save collinsb/c95ffa5e7ca538ba7bd8 to your computer and use it in GitHub Desktop.
Save collinsb/c95ffa5e7ca538ba7bd8 to your computer and use it in GitHub Desktop.
Codeigniter Basic File (image) Upload
public function imgUpload($file) {
$config['upload_path'] = './assets/property/images/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '6000000';
$config['max_width'] = '10024';
$config['max_height'] = '5768';
//load codeigniter upload helper/libary/magic thing
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($file))
{
//upload error, return false
$error = array('error' => $this->upload->display_errors());
return false;
}
else
{
//upload success, return uploaded file name
$data = array('upload_data' => $this->upload->data());
return $data['upload_data']['file_name'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment