callback_after_upload
void callback_after_upload( mixed $callback )
Quick Description: A callback that triggered after the upload functionality.
Available for version >= 1.2
A callback that triggered after the upload functionality. This is very useful if you want to resize the file, create thumbnail, zip it e.t.c.
I have an example with a simple resizing using image moo for the callback_after_upload
function employees_management() { $crud = new grocery_CRUD(); $this->load->config('grocery_crud'); $this->config->set_item('grocery_crud_file_upload_allow_file_types', 'gif|jpeg|jpg|png'); $crud->set_table('employees'); $crud->set_relation('officeCode','offices','city'); $crud->display_as('officeCode','Office City'); $crud->set_subject('Employee'); $crud->set_field_upload('file_url','assets/uploads/images'); $crud->callback_after_upload(array($this,'example_callback_after_upload')); $output = $crud->render(); $this->_example_output($output); } /* * Examples of what the $uploader_response, $files_to_upload and $field_info will be: $uploader_response = Array ( [0] => stdClass Object ( [name] => 6d9c1-52.jpg [size] => 495375 [type] => image/jpeg [url] => http://grocery_crud/assets/uploads/files/6d9c1-52.jpg ) ) $field_info = stdClass Object ( [field_name] => file_url [upload_path] => assets/uploads/files [encrypted_field_name] => sd1e6fec1 ) $files_to_upload = Array ( [sd1e6fec1] => Array ( [name] => 86.jpg [type] => image/jpeg [tmp_name] => C:\wamp\tmp\phpFC42.tmp [error] => 0 [size] => 258177 ) ) */ function example_callback_after_upload($uploader_response,$field_info, $files_to_upload) { $this->load->library('image_moo'); //Is only one file uploaded so it ok to use it with $uploader_response[0]. $file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name; $this->image_moo->load($file_uploaded)->resize(800,600)->save($file_uploaded,true); return true; }