[eluser]Asinox[/eluser]
yes, i hav foreach, but i got the error:
Code:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: libraries/Upload.php
Line Number: 152
plus in the view
Code:
You did not select a file to upload.
Where's the problem ?
controller
Code:
class Test extends Controller{
function Test(){
parent::Controller();
$this->load->model('panel/test_model');
$this->load->helper(array('form','url','file'));
$this->_container = $this->config->item('FAL_template_dir').'template_admin/container';
}
function subir_test(){
$data['heading']=' >> Test de upload multiple';
$data['page'] = $this->config->item('FAL_template_dir').'template_admin/panel/test_view';
$this->load->vars($data);
$this->load->view($this->_container);
}
function do_upload(){
$config['upload_path'] = './test';
$config['allowed_types'] = 'gif|jpg|png|flv';
$config['max_size'] = '2048';
$this->load->library('upload');
foreach($_FILES as $key => $valor){
//if(!empty($_FILES[$key])){
$this->upload->initialize($config);
if(! $this->upload->do_upload($key)){
$data['error'][] = $this->upload->display_errors();
$data['heading']=' >> Subieron??';
$data['page'] = $this->config->item('FAL_template_dir').'template_admin/panel/test_bien_view';
}else{
$this->test_model->procesar_archivos();
}
//}
}
$data['heading']=' >> Subieron??';
$data['page'] = $this->config->item('FAL_template_dir').'template_admin/panel/test_bien_view';
$this->load->vars($data);
$this->load->view($this->_container);
}
}
Model
Code:
class Test_model extends Model{
function Test_model(){
parent::Model();
$this->load->database();
$this->load->library('image_lib');
}
function procesar_archivos(){
$upload = array($this->upload->data());
$this->load->library('image_lib');
foreach($upload as $key[] => $valor){
if($valor['is_image'] != 1){
$video = $valor['file_name'];
}elseif($valor['is_image'] == 1){
$config['image_library'] = 'GD2';
$config['source_image'] = $valor['full_path'];
$config['create_thumb'] = TRUE;
$config['thumb_marker'] = '_tn';
$config['master_dim'] = 'width';
$config['quality'] = 75;
$config['maintain_ratio'] = TRUE;
$config['width'] = 175;
$config['height'] = 175;
$config['new_image'] = '/test/imagen/thumbs/'.$valor['file_name'];
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
}
}
}
view
Code:
echo form_open_multipart('admin/test/do_upload');
echo "Imagen ". form_upload('userfile[]').'<Br>';
echo "Video ". form_upload('userfile[]').'<Br>';
echo form_submit('','Subir Archivos');
echo form_close();
Thanks