⚠ 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 not working



bob jones
  • profile picture
  • Member

Posted 21 May 2012 - 21:15 PM

Hello everyone,

I am having a problem with a callback.




$crud->columns('description','slideshow','price','address_number', 'address_street', 'address_city', 'address_province', 'address_country', 'address_postal' , 'contact_name', 'contact_email', 'contact_home_phone', 'contact_cell_phone', 'contact_form_email');
$crud->set_field_upload('slideshow','assets/uploads/files');
$crud->unset_back_to_list();

$crud->callback_after_upload(array($this,'example_callback_after_upload'));
$output = $crud->render();
$this->_example_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(800,600)->save($file_uploaded,true);
return true;
}





This example comes right out of the documentation (http://www.grocerycr...ck_after_upload ), but I can't get it working. I have checked and the file is being uploaded to the correct folder on my server.

Can anyone see what I'm doing wrong? The callback appears to be ignored.

Thanks in advance,

B

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

Posted 23 May 2012 - 21:26 PM

Hello [member='bob jones'] and sorry for the delayed answer.

I checked this function and it works fine for me.

When you say that the callback appears to be ignored what do you mean exactly? So the upload is working normally? The only thing that the callback at the examples do is to resize the image with a maximum width 800px and maximum height 600px at the same file name , nothing more. So what is happening exactly?

Did you check your folder for permissions? Are you sure that your folder has 777 as permission to the folder? Did you check your image if it is resized? For example if an image is 400px X 300px it will not be resized. If the image is 1024px x 768px it will be resize to 800px X 600px because it exceeded the maximum width and height.