⚠ 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 forum is read-only and soon will be archived. ⚠


Grocerycrud callback_after_upload() has not effect

callback_after_upload()

  • Please log in to reply
1 reply to this topic

#1 Mrinal Rajpurohit

Mrinal Rajpurohit

    Member

  • Members
  • PipPip
  • 14 posts

Posted 05 January 2014 - 12:14 PM

I am trying to use grocery crud for generating crud. One of my forms requires the image to thumbnailed on the fly. For this I resorted to callback->after->upload() provided in the grocery crud. But it simply doesn't get fired. Here is my controller code:
 

class Categories extends CI_Controller {

public function __construct()
{
parent::__construct();

$this->load->library('grocery_CRUD');
}

public function index()
{

$crud = new grocery_CRUD();
$crud->set_table('categories');
$crud->set_subject('Category');
$crud->required_fields('name');
$crud->unset_export();
$crud->unset_print();
$crud->unset_read();
$crud->set_field_upload('image','assets/uploads/files');
$crud->callback_after_upload(array($this,'thumbnailer'));

//$crud->columns('city','country','phone','addressLine1','postalCode');

$output = $crud->render();

$this->load->view('gcrud',$output);


}

   public function thumbnailer($uploader_response,$field_info,$files_to_upload)
{
      
       
        $this->load->library('image_moo');

                  $source=$field_info->upload_path."/".$uploader_response[0]->name;
              
                  $thumbnails=$field_info->upload_path.'/thumbnails/'.$uploader_response[0]->name;
                  $large_images=$field_info->upload_path.'/large_images/'.$uploader_response[0]->name;
                  $this->image_moo->load($source)->resize(180,350)->save($thumbnails,false);
  $this->image_moo->load($source)->resize(400,600)->save($large_images,false);
                  return true;
                              
}


}
 
It works like there is no such line "$crud->callback_after_upload(array($this,thumbnailer))"
Tried Everything. Clueless!
 

 

 



#2 Kun Hernowo Putra

Kun Hernowo Putra

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 17 February 2014 - 09:22 AM

 

I am trying to use grocery crud for generating crud. One of my forms requires the image to thumbnailed on the fly. For this I resorted to callback->after->upload() provided in the grocery crud. But it simply doesn't get fired. Here is my controller code:
 

class Categories extends CI_Controller {

public function __construct()
{
parent::__construct();

$this->load->library('grocery_CRUD');
}

public function index()
{

$crud = new grocery_CRUD();
$crud->set_table('categories');
$crud->set_subject('Category');
$crud->required_fields('name');
$crud->unset_export();
$crud->unset_print();
$crud->unset_read();
$crud->set_field_upload('image','assets/uploads/files');
$crud->callback_after_upload(array($this,'thumbnailer'));

//$crud->columns('city','country','phone','addressLine1','postalCode');

$output = $crud->render();

$this->load->view('gcrud',$output);


}

   public function thumbnailer($uploader_response,$field_info,$files_to_upload)
{
      
       
        $this->load->library('image_moo');

                  $source=$field_info->upload_path."/".$uploader_response[0]->name;
              
                  $thumbnails=$field_info->upload_path.'/thumbnails/'.$uploader_response[0]->name;
                  $large_images=$field_info->upload_path.'/large_images/'.$uploader_response[0]->name;
                  $this->image_moo->load($source)->resize(180,350)->save($thumbnails,false);
  $this->image_moo->load($source)->resize(400,600)->save($large_images,false);
                  return true;
                              
}


}
 
It works like there is no such line "$crud->callback_after_upload(array($this,thumbnailer))"
Tried Everything. Clueless!
 

 

 

 

hello mrinal
i have a problem with my upload image by url
can u help me 

public function product(){
   
        
        if($this->session->userdata('logged_in')){
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
            $this->load->view('administrator', $data);
        }
        else{
            redirect('login','refresh');
        }
        
        $crud = new grocery_CRUD();
        $crud->set_table('product');
        $crud->set_subject('Product');
        $crud->required_fields('productName');
        $crud->columns('productCategoryId','productName', 'productDescription','active');
        $crud->display_as('productCategoryId', 'Product Category');
        $crud->display_as('productName', 'Product Name');
        $crud->display_as('productDescription', 'Product Description');
        $crud->display_as('imageDefault', 'Image');
$crud->display_as('imageBack', 'Image Back');
        $crud->display_as('sortOrder', 'Sort Order');
        $crud->field_type('dateAdd', 'hidden');
        $crud->field_type('dateEdit', 'hidden');
$crud->set_field_upload('imageDefault','../images/product/');
        /*
        $crud->set_field_upload('imageDefault','../images/');
        $crud->set_field_upload('image1','../images/');
$crud->set_field_upload('image2','../images/');
        $crud->set_field_upload('image3','../images/');
$crud->set_field_upload('imageBack','../images/');
$crud->callback_before_insert(array($this,'set_image'));
*/
//$crud->callback_after_upload(array($this,'set_image1'));

$crud->callback_before_insert(array($this,'set_image1'));
        $crud->set_relation('productCategoryId', 'product_category', 'categoryURL');
$crud->set_relation('active','aktivasi','active');

        $crud->unset_export();
        $crud->unset_print();
        
        $output = $crud->render();
        $this->product_crud($output);
              
    }

    public function product_crud($output = NULL){
        
        $this->load->view('product.php',$output);
    }  

function set_image1($post_array) {

$this->db->select('product_category.categoryURL');
$this->db->from('product_category');
$this->db->where('id',$post_array);
$post_array['categoryURL'] = $post_array['categoryURL'] . $post_array['imageDefault'];

return $post_array;
}  

     

Tq before






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users