0
我正在與雜貨店的後端部分操作crud,我需要上傳5張圖片(其中3個具有相同的寬度和高度,另外2個具有不同大小),但是,當我嘗試用set_field_upload
上傳,所有文件都上傳一個尺寸。我預計diferents大小。我試過GD2
(Codeigniter
版本),但我不知道grocery_crud
是否可以做到這一點。與Grocery Crud的多個上傳
public function marcas(){
$this -> load -> view('header');
$this -> load -> view('leftbar');
$this -> grocery_crud -> set_theme('datatables');
$this -> grocery_crud -> set_table('marcas');
$this -> grocery_crud -> set_subject('Marcas');
$this -> grocery_crud -> columns('nombre','descripcion','texto','logo');
$this -> grocery_crud -> set_relation('id_tipo_marca','tipo_marcas','nombre');
$this -> grocery_crud -> display_as('id','ID');
$this -> grocery_crud -> display_as('id_tipo_marca','Tipo Marca');
$this -> grocery_crud -> display_as('nombre','Nombre');
$this -> grocery_crud -> display_as('descripcion','Descripcion');
$this -> grocery_crud -> display_as('texto','Texto');
$this -> grocery_crud -> display_as('link','Link');
$this -> grocery_crud -> display_as('logo','Logo');
$this -> grocery_crud -> set_field_upload('logo','../img');
$this -> grocery_crud -> callback_after_upload(array($this, 'example_callback_after_upload_logo'));
$this -> grocery_crud -> display_as('imagen','Imagen Grande');
$this -> grocery_crud -> display_as('imagen2','Imagen Pequeña 1');
$this -> grocery_crud -> display_as('imagen3','Imagen Pequeña 2');
$this -> grocery_crud -> display_as('imagen4','Imagen Pequeña 3');
$this -> grocery_crud -> set_field_upload('imagen','../img/grande');
$this -> grocery_crud -> callback_after_upload(array($this, 'example_callback_after_upload_grande'));
$this -> grocery_crud -> set_field_upload('imagen2','../img/thumb');
$this -> grocery_crud -> set_field_upload('imagen3','../img/thumb');
$this -> grocery_crud -> set_field_upload('imagen4','../img/thumb');
$this -> grocery_crud -> callback_after_upload(array($this, 'example_callback_after_upload_thumb'));
$output = $this -> grocery_crud -> render();
$this -> _example_output($output);
$this -> load -> view('footer');
}
function example_callback_after_upload_grande($uploader_response,$field_info,$files_to_upload){
$this -> load -> library ('image_moo');
$file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;
$this -> image_moo -> load($file_uploaded) ->resize_crop(317,140)->save($file_uploaded, true);
return true;
var_dump($uploader_response);die;
function example_callback_after_upload_logo($uploader_response,$field_info,$files_to_upload){
$this -> load -> library ('image_moo');
$file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;
$this -> image_moo -> load($file_uploaded) ->resize(125,83)- >save($file_uploaded, true);
return true;
var_dump($uploader_response);die;
}
function example_callback_after_upload_thumb($uploader_response,$field_info,$files_to_upload){
$this -> load -> library ('image_moo');
$file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;
$this -> image_moo -> load($file_uploaded) ->resize_crop(317,140)->save($file_uploaded, true);
return true;
var_dump($uploader_response);die;
}
你能解釋它是如何工作的/它基本上做了什麼?我有類似的問題,它看起來像你的解決方案將適合,但我不知道。 – voghDev 2014-06-03 10:56:32