Welcome Guest, Not a member yet? Register   Sign In
Latavish's Multiple Image Upload with Thumbnail Generation
#3

[eluser]webbymonk[/eluser]
Thanks lavatish, finally i can make it works...
here is my code

Controller
Code:
function upload_tour_pic() {
        $this->load->helper(array('form','url','file'));
        $data['title'] = "Upload Pictures";
        $data['query'] = $this->tour_model->get_tour();
        $this->load->view('upload_tour_pic', $data);
}
    
function picupload()
{
        //Load Model
        $this->load->helper(array('form','url','file'));
        $this->load->model('Process_image');
        $this->load->model('tourpic_model');
        $this->load->library('upload');
        $this->load->library('validation');
        
        $gmt=false;
        $time = ($gmt)  ? gmstrftime("%Y-%m-%d %H:%M:%S", time()) : strftime("%Y-%m-%d %H:%M:%S", time());
        
    
        
        $picInfo = array(
                'tour_id' => (int) $this->input->post('tour_id'),
                'timestamp' => $time
        );

        
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '8048'; //2 meg

        
        $data['extraHead'] = "<link href=\"" .base_url()."css/admin.css\" rel=\"stylesheet\" type=\"text/css\" />";

        $i=1;
        $j=1;
        foreach($_FILES as $key => $value)
        {
            if( ! empty($key['name']))
            {
                $this->upload->initialize($config);
                $data['title'] = 'Files Upload!';
                if ( !$this->upload->do_upload($key))
                {
                    $data['error'][$j] =  $this->upload->display_errors();    
                    $j++;
                }    
                else
                {
                    $this->Process_image->process_pic($picInfo);
                    $data['success'] = 'Thank You, Files Upladed!';
                    $data['upload_data'][$i]  = $this->upload->data();
                    $i++;
                }
            }
        }
        
        
        
            $data['query'] = $this->tour_model->get_tour();
            $data['rowpic'] = $this->tourpic_model->get_pic_code($picInfo);
            $data['countdata'] = count($data['upload_data']);
            $data['counterr'] = count($data['error']);
            
            //$data['query'] = $this->tourpic_model->get_pic_code($picInfo);
            $this->load->view('upload', $data);
            
            
            
    }

now I think i want to add some fields for the image, like title and description...
Do anyone have idea how to loop array of fields and insert it into database..
For example:
image1 - title1 - desc1
image2 - title2 - desc2
image3 - title3 - desc3

Code:
<input type="text" name="pic_title[]" value="" />
<textarea name="pic_desc[]"></textarea>

<input type="text" name="pic_title[]" value="" />
<textarea name="pic_desc[]"></textarea>

<input type="text" name="pic_title[]" value="" />
<textarea name="pic_desc[]"></textarea>

Thanks...


Messages In This Thread
Latavish's Multiple Image Upload with Thumbnail Generation - by El Forum - 07-11-2008, 11:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB