Jump to content


callback_after_upload not working

callback_after_upload

  • Please log in to reply
4 replies to this topic

#1 tofayelahmed

tofayelahmed

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts

Posted 15 April 2012 - 12:23 PM

I use the documetation of callback_after_upload.
But it show an error message.
Fatal error: 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.

#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,155 posts
  • LocationLondon

Posted 15 April 2012 - 12:30 PM

callback_after_upload is only for version 1.2 or later
Posted Image

#3 tofayelahmed

tofayelahmed

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts

Posted 16 April 2012 - 11:20 AM

Thanx johnny. I use version 1.1.8.

#4 tofayelahmed

tofayelahmed

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts

Posted 24 April 2012 - 12:19 PM

hello everybody.
I want to display a thumbnail of an image instead of its name in the list page.
I use latest grocery crud version.
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;
}


#5 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,155 posts
  • LocationLondon

Posted 24 April 2012 - 09:44 PM

The 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.
Posted Image





Also tagged with one or more of these keywords: callback_after_upload

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users