Welcome Guest, Not a member yet? Register   Sign In
Problem with multiple uploading image
#1

[eluser]SaSa[/eluser]
I use codeigniter. I want multiple upload image, for this work, i use library Multi_upload and jquery.MultiFile.

i have in output, this: "Array ( [0] => [1] => [2] => ) no" => this is is from line 18 "(print_r($error);echo 'no'Wink" in the my code, and inserted to databse table this: "[]"(i want insert file name) . how can fix it?

My Html:http://pastebin.com/8YWJS2hy

library Multi_upload: http://pastebin.com/115ASstV

jquery.MultiFile: http://pastebin.com/0cyU8HvA

My Controller:
Code:
function insert_data(){
        $config['upload_path']   = './uploads/'; // server directory
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']      = '512';
        
        $this->load->library('Multi_upload');
        $error = array();
        $data  = array();
        for ($i = 0; $i < count($_FILES['userfile']['name']); $i++) {
            $this->upload->initialize($config);
            if (!$this->multi_upload->go_upload('userfile', $i)) {
                $error[] = $this->upload->display_errors();
            }
            $data[$i] = $this->multi_upload->go_upload();
            //gradually build up upload->data()
        }
        
        if (count($error) > 0) {
            print_r($error); //Line 18
            echo 'no';
        } else {
            print_r($data);
            echo 'ok';
        }
        
        $data = array(
            //'name' => $this -> input -> post('name'),
            //'term' => $this -> input -> post('term'),
            'image' => json_encode($data)
        );
        
        $this->db->insert('table', $data);
    }




Theme © iAndrew 2016 - Forum software by © MyBB