⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

callback_after_upload not working



tofayelahmed
  • profile picture
  • Member

Posted 15 April 2012 - 12:23 PM

I use the documetation of callback_after_upload.
But it show an error message.
[b]Fatal error[/b]: Call to undefined method grocery_CRUD::callback_after_upload().
My code is below:

$this->grocery_crud->callback_after_upload(array($this,'image_callback_after_upload'));
function image_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;
}

Sorry i post this the wrong place.
Please pardon.

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 15 April 2012 - 12:30 PM

callback_after_upload is only for version 1.2 or later

tofayelahmed
  • profile picture
  • Member

Posted 16 April 2012 - 11:20 AM

Thanx johnny. I use version 1.1.8.

tofayelahmed
  • profile picture
  • Member

Posted 24 April 2012 - 12:19 PM

hello everybody.
I want to [color=#333333][font=arial, sans-serif][size=4]display a[/size][/font][/color] [color=#333333][font=arial, sans-serif][size=4]thumbnail[/size][/font][/color] [color=#333333][font=arial, sans-serif][size=4]of an image[/size][/font][/color] [color=#333333][font=arial, sans-serif][size=4]instead of its[/size][/font][/color] [color=#333333][font=arial, sans-serif][size=4]name in the list page.[/size][/font][/color]
[color=#333333][font=arial,sans-serif][size=4]I use latest grocery crud version.[/size][/font][/color]
I use "callback_after_upload" but its not working.
My code is below:

function employee_setup ()
{
$this->grocery_crud->set_table('members');
$this->grocery_crud->set_subject('Member Setup');
$this->grocery_crud->required_fields('first_name','last_name','address_1','email','mobile','username','password');
$this->grocery_crud->set_rules('password','Password','required|min_length[6]|callback_password_check');
$this->grocery_crud->set_rules('username','Username','required|callback_username_check');
$this->grocery_crud->set_rules('email', 'Email', 'valid_email|required');
$this->grocery_crud->set_field_upload('image','img/mem_image');
$this->grocery_crud->callback_after_upload(array($this,'example_callback_after_upload'));
$this->grocery_crud->unset_columns('address_1','address_2','status','member_type','create_date');
$this->grocery_crud->change_field_type('password','password');
$this->grocery_crud->display_as('address_1','First Address')->display_as('address_2','Second Address');

$this->poscrud_output($output);
}
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(50,50)->save($file_uploaded,true);

return true;
}

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 24 April 2012 - 21:44 PM

The [color=#282828][font=helvetica, arial, sans-serif]callback_after_upload is not for that reason. The functionality to create a thumbnail is not yet at grocery CRUD so you have to change the core library to this.[/font][/color]