Welcome Guest, Not a member yet? Register   Sign In
Why does uploading images fail in this application?
#1

(This post was last modified: 09-03-2020, 04:38 AM by Ajax30.)

I am working on a Social Network application with Codeigniter 3, Ioan-Auth and Bootstrap 4. More details HERE.

The code below correctly hashes the filename before inserting it in the avatar column, but the upload itself never happens.


Code:
if ($this->form_validation->run() === TRUE)
    {
        //more code here

        $config['upload_path'] = './assets/img/avatars';
        $config['file_ext_tolower']     = TRUE;
        $config['allowed_types']        = 'gif|jpg|jpeg|png';
        $config['max_size']             = 1024;
        $config['max_width']            = 1024;
        $config['max_height']           = 1024;
        $config['encrypt_name']         = TRUE;
        $this->load->library('upload', $config);

        if (!$this->upload->do_upload('userfile')){
            $error = array('error' => $this->upload->display_errors());
            $file_name = null;
        } else {
            $file_name = $this->upload->data('file_name');
        }

        $additional_data = [
            'first_name' => $this->input->post('first_name'),
            'last_name' => $this->input->post('last_name'),
            'avatar' =>  $file_name,
            'company' => $this->input->post('company'),
            'phone' => $this->input->post('phone'),
        ];
}

I have a XAMPP server on Windows 10, so it is unlikely that there are permission issues on the images folder.
Reply


Messages In This Thread
Why does uploading images fail in this application? - by Ajax30 - 09-03-2020, 04:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB