⚠ 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 works in localhost but not on hosting site. if i disable callback file uploads



Zaraq K Bangash
  • profile picture
  • Member

Posted 14 August 2016 - 10:32 AM

Hello guys i need help I am new to grocery_CRUD and i m not even expert in codeigniter. I recently used grocery_curd it was very easy to implement but I have an issue in callback_after_upload. this calback function works fine in localhost enviroment (wamp win 8.1) but when i upload file to server it give me an error and file is not upload. when i disable callback function files uploads successfully. actually i m resize file after file uploaded to create thumb.
kindly see my code and help.

 

public function portfolio_detail()
    {
        if(($this->session->userdata('logged_in')==TRUE) && ($this->session->userdata('role')== 'admin'))
        {
        $crud = new grocery_CRUD();
        
        //$crud->set_theme('datatables');
        $this->load->config('grocery_crud');
        $this->config->set_item('grocery_crud_file_upload_allow_file_types','gif|jpeg|jpg|png');        //allowed files types
        
        //$crud->callback_after_upload(array($this,'resize_image'));
        
        $crud->set_table('portfolio');
        $crud->set_subject('Portfolio');
        $crud->required_fields('title','img_full','img_title','project_desc');
        
        $crud->set_relation('category','project_types','project_type');
        
        $crud->set_field_upload('img_full','assets/images/files'); // used to set input type file upload
        $crud->callback_after_upload(array($this,'resize_image'));
        
            $output =$crud->render();
            
            $data['config']=$this->AdminModel->portfolio();
        
            $this->_example_output($output);
            }else
        {
            $this->session->set_flashdata('msg', 'Please login first!!!');
            redirect('Admin/index');
            }
    }

and callback function code is: i also added thumbnail folder to separate resized images from actual folder, this works fine in wamp
 

function resize_image($uploader_response,$field_info, $files_to_upload)
        {
        $this->load->library('image_moo');
        
        
        $file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;
        $thumbnail = $field_info->upload_path.'/thumbnail/'.$uploader_response[0]->name;

        $this->image_moo->load($file_uploaded)->save($file_uploaded,true);
        $this->image_moo->load($file_uploaded)->resize(280,180)->save($thumbnail,true);
     
        return true;
        
        }

more interestingly when i call callback function

$crud->callback_after_upload(array($this,'resize_image'));

 

in local wamp environment  before file upload function/code

$crud->set_field_upload('img_full','assets/images/files');

 

it still works fine but one server i doesnt work anywhere i put it . then only file uploads when i remove callback function
I am using grocery_crud 1.5.5 and codeigniter v 3.1.0
kindly please help me i m stuck dont have expert skills to fix such issues.