Jump to content


How to set fields after upload with file information

after_upload upload fields set

  • Please log in to reply
No replies to this topic

#1 Gonzalo Morel

Gonzalo Morel

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 05 May 2016 - 05:47 PM

hello:

 

i have a question: how i use the data to set fields, example obtain size and extension to send to fields on callback_after_upload,

 

i try to create two vars $extension and $size but doesn't work

 

 

 

PD: sorry for my english.

 

public function images()
    {
        $crud = new Grocery_CRUD();


        $crud->set_table('gm_imgs');


        $crud->order_by('image_id', 'asc');


        $crud->set_relation('customer_id', 'gm_customers', 'customer_name');


        $crud->columns('imagen','image_name', 'customer_id', 'image_type', 'image_extension', 'image_size');
        
        $crud->unset_add_fields('image_active');
        
        $crud->field_type('image_random', 'hidden', 'abcdefghij');
        $crud->field_type('image_md5', 'hidden', ' ');
        $crud->field_type('image_size', 'hidden');
        $crud->field_type('image_active', 'true_false');        
        $crud->field_type('image_type', 'dropdown',array('1' => 'botón', '3' =>'icono', '0' => 'Logos y fondos'));
        $crud->set_field_upload('image_extension', 'assets/uploads/files'); 


        $crud->display_as('customer_id', 'Cliente')
                ->display_as('image_type', 'Tipo')
                ->display_as('image_md5', 'Encriptación')
                ->display_as('image_random', 'Nombre aleatorio')
                ->display_as('image_extension', 'imágen')
                ->display_as('image_size', 'Peso de imágen')
                ->display_as('image_active', 'Activo')
                ->display_as('image_name', 'Nombre');
        
        
        
        $crud->callback_after_upload(array($this,'callback_after_upload'));
        
        $crud->callback_before_insert(array($this,'obten_data_image_callback'));
        $crud->callback_before_update(array($this,'obten_data_image_callback'));


        $crud->unset_jquery();


        $output = $crud->render();


        $this->salida($output);
    }
 
public function callback_after_upload($uploader_response,$field_info, $files_to_upload)
    {
        
        $field = $field_info->encrypted_field_name;
        $this->setImage_size($files_to_upload[$field]['size']);
        $extension = explode('/',$files_to_upload[$field]['type']);
        $this->setExtension($extension[1]);
        
        return $this;
        
    }
public function obten_data_image_callback($post_array)
    {
        $post_array['image_extension'] = $this->getExtension();
        $post_array['image_size'] = $this->getImage_size();
        return $post_array;
    }

 

 

 







Also tagged with one or more of these keywords: after_upload, upload, fields, set

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users