[eluser]Asinox[/eluser]
Thanks, im trying this but i hav a litter problem....
im trying to upload a images and a video, just the video is uploaded and ur data go to the database, but the images dont work.
in my view file i have this:
Code:
<span>Seleccionar Galería</span>
<?php
if(isset($errors)){
echo $errors;
}
?>
<?php echo form_open_multipart('admin/videos/procesar');?>
<select name="galeria_id">
<option value="" selected>Seleccione una Galería</option>
<option value="" >-----------------------------</option>
<?php
foreach($query as $row):
echo '<option value="'.$row->galeria_id.'">'.$row->galeria.'</option>';
endforeach;?>
</select>
echo '<span>Imágen</span>';
echo form_upload('userfile');
echo '<span>Video</span>';
echo form_upload('userfile');
echo '<br>'.form_textarea('descripcion');
echo '<br>'.form_submit('','Subir Video');
echo form_close();
?>
the user's file name's are "userfile" and is ok, but when the name's are "userfile[]" i got a blank pages.
in my controller:
Code:
function procesar(){
/*$imagen_var = 'userimagen';
$video_var = 'uservideo';*/
$config['upload_path'] = './public/videos';
$config['allowed_types'] = 'gif|jpg|png|flv';
$config['max_size'] = '2048';
/*$config['max_width'] = '1024';
$config['max_height'] = '768'; */
$config['overwrite'] = FALSE;
$config['encrypt_name'] = TRUE;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
//$this->upload->initialize($config);
foreach($_FILES as $key => $value):
if ( ! $this->upload->do_upload($key)){
//$errors[] = $this->upload->display_errors();
$data['errors'] = $this->upload->display_errors();
$data['heading'] = '>> Agregar Videos';
$data['query']= $this->galerias_model->listar();
$data['page'] = $this->config->item('FAL_template_dir').'template_admin/panel/agregar_videos_view';
$this->load->vars($data);
$this->load->view($this->_container);
}else{
$this->videos_model->procesar();
redirect('admin/videos');
}
endforeach;
}
and my model
Code:
function procesar(){
$uploads = array($this->upload->data());
$this->load->library('image_lib');
foreach($uploads as $key[] => $value):
if($value['file_ext'] != 'flv'){
$config['image_library'] = 'GD2';
$config['source_image'] = $value['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;
//$thumb = 'tb_'.$data['file_name'];
$config['new_image'] = './public/videos/thumbs/'.$value['file_name'];
$thumb = $config['new_image'];
$this->image_lib->initialize($config);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->db->set('thumbs',$thumb);
}elseif($value['file_ext']=='flv'){
$this->db->set('video',$value['file_name']);
}
$this->db->set('galeria_id',$this->input->post('galeria_id'));
$this->db->set('descripcion',$this->input->post('descripcion'));
//$this->db->set('video',$value['file_name']);
//$this->db->set('thumbs',$thumb);
$query = $this->db->insert('videos');
endforeach;
}