Created
May 28, 2015 20:36
-
-
Save collinsb/c95ffa5e7ca538ba7bd8 to your computer and use it in GitHub Desktop.
Codeigniter Basic File (image) Upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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