Welcome Guest, Not a member yet? Register   Sign In
Upload 2 different kind of file in the same time ?
#1

[eluser]Asinox[/eluser]
hi, how i know if of my field upload one was sent o both?, the problem is that i need to upload a picture and a video, but the last process is different for both....

Thanks
#2

[eluser]Colin Williams[/eluser]
[quote author="Asinox" date="1216619362"]hi, how i know if of my field upload one was sent o both?, the problem is that i need to upload a picture and a video, but the last process is different for both....

Thanks[/quote]

The do_upload method returns TRUE or FALSE based on whether it succeeds or not, so just assign each method result to separate variables, then use those variables to check for "what happened" later on in the process.
#3

[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&iacute;a</span>
&lt;?php
if(isset($errors)){
    echo $errors;
}
?&gt;
&lt;?php echo form_open_multipart('admin/videos/procesar');?&gt;
<select name="galeria_id">
<option value="" selected>Seleccione una Galer&iacute;a</option>
<option value="" >-----------------------------</option>
&lt;?php
foreach($query as $row):
echo '<option value="'.$row->galeria_id.'">'.$row->galeria.'</option>';
endforeach;?&gt;
</select>
echo '<span>Im&aacute;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();
?&gt;
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;
    }




Theme © iAndrew 2016 - Forum software by © MyBB