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

梦想的初衷 提交于 2019-12-02 06:15:53

问题


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 ?


回答1:


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);
}


来源:https://stackoverflow.com/questions/30523528/set-field-upload-how-to-custom-multi-image-upload-in-grocery-crud-library-on-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!