Search code examples
phpcodeignitergrocery-crud

set_field_upload - how to custom multi image upload in grocery_CRUD library on codeigniter?


I need to upload multiple image from grocery_CRUD Library on codeigniter framework.

I need step by step process !

$crud->set_field_upload('image','assets/uploads/products');
$crud->callback_after_upload(array($this,'resize_after_upload'));

Now this is working as a single image upload only. Anybody please to help ?


Solution

  • Try Grocery_Crud_Multiuploader library, I wrote long back, might help you, instructions are given in github, current library supports files as well as images

    grocery_crud_multiuploader

    Load library like below

    function __construct()
    {
           parent::__construct();
           $this->load->database();
           $this->load->helper('url');
           $this->load->library('grocery_CRUD');
           $this->load->library('Grocery_CRUD_Multiuploader');
    }
    

    In controller function

    public function multi_upload()
    {
       $crud = new Grocery_CRUD_Multiuploader(); 
       $crud->set_table('content');
       $crud->where('state', 1);   
       ...
       ...
       $config = array(
            /* Destination directory */
            "path_to_directory" =>'assets/grocery_crud_multiuploader/GC_uploads/pictures/',
    
           /* Allowed upload type */
          "allowed_types" =>'gif|jpeg|jpg|png',
    
          /* Show allowed file types while editing ? */
          "show_allowed_types" => true,
    
         /* No file text */
         "no_file_text" =>'No Pictures',
    
         /* enable full path or not for anchor during list state */
         "enable_full_path" => false,
    
         /* Download button will appear during read state */
         "enable_download_button" => true,
    
         /* One can restrict this button for specific types...*/
        "download_allowed" => 'jpg'
      );
    
      $crud->new_multi_upload("image",$config);
      ...
      ...
      $output = $crud->render();
      $this->_example_output($output);
    }