Created
April 2, 2018 17:01
-
-
Save RohanPhpDev/8dd9fa465b8b2889663ec4d22c3702dd to your computer and use it in GitHub Desktop.
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
function upload($folder_name,$field_name,$allow_type='',$size=500){ | |
//echo $allow;die(); | |
$CI =& get_instance(); | |
$config['upload_path'] = './upload/'.$folder_name; | |
$config['allowed_types'] = $allow_type; | |
$config['max_size'] = $size; | |
$new_name = time().$_FILES[$field_name]['name']; | |
$config['file_name'] = $new_name; | |
$CI->load->library('upload', $config); | |
$CI->upload->overwrite = true; | |
if ( ! $CI->upload->do_upload($field_name)){ | |
$error = array('status'=>FALSE,'error' => $CI->upload->display_errors()); | |
return($error); | |
} | |
else | |
{ | |
$data = array('status'=>TRUE,'upload_data' => $CI->upload->data()); | |
return($data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment