0

hi everyone i have problem with uploading class codeigniter.. upload not working and not input to database.. i think in function if not working but how? in my other code i usually use this code is always working..

this function i think not work

if ($this->upload->do_upload('cv')) {
   $data = $this->upload->data();
   $cv = $this->createImageOne($data);
}

if ($this->form_validation->run() === TRUE) {

        $nik = $this->input->post('nik', true);
        $employee_name = trim(addslashes($this->input->post('employee_name', true))); 
        $email = trim(addslashes($this->input->post('email', true)));
        $sex = trim(addslashes($this->input->post('sex', true))); 
        $bornplace = trim(addslashes($this->input->post('bornplace', true)));
        $borndate = trim(date('Y-m-d', strtotime($this->input->post('borndate', true))));
        $address = trim(addslashes($this->input->post('address', true)));
        $tlp = trim(addslashes($this->input->post('tlp', true)));
        $education = trim(addslashes($this->input->post('education', true)));
        $position = trim(addslashes($this->input->post('position', true)));
        $vendor = trim(addslashes($this->input->post('vendor', true)));
        $gapok = trim(addslashes($this->input->post('gapok', true)));
        $start_date = trim(date('Y-m-d', strtotime($this->input->post('start_date', true))));
        $end_date = trim(date('Y-m-d', strtotime($this->input->post('end_date', true))));
        $status = trim(addslashes($this->input->post('status', true)));

        $this->load->library('image_lib');
        $config['upload_path'] = $this->config->item('upload_temp');

        $config['allowed_types'] = '*';
        $config['max_size'] = '1000000';
        $config['max_width'] = '2048';
        $config['max_height'] = '2048';

        $this->load->library('upload', $config);


        $cv = '';
        $foto = '';



        if ($this->upload->do_upload('cv')) {
            $data = $this->upload->data();
            $cv = $this->createImageOne($data);
        }



        if ($this->upload->do_upload('foto')) {
            $datafour = $this->upload->data();
            $foto = $this->createImageFour($datafour);
        }

        $this->Mkaryawan->insert_karyawan($nik, $employee_name, $email, $sex, $bornplace, $borndate, $address, $tlp, $education, $position, $vendor, $gapok, $start_date, $end_date, $status, $cv, $foto);


    }

1 Answers1

0

You can remove the following line of code. As if the file upload works perfectly then you can apply more validations:

$this->load->library('image_lib');

$config['max_size'] = '1000000'; $config['max_width'] = '2048'; $config['max_height'] = '2048';

As a reference, you can follow this link to upload single/multiple files in CodeIgniter