不需要图像 CodeIgniter 3。如何?

No image required CodeIgniter 3. How?

我在验证图像是否被选中时遇到问题。我使用 CodeIgniter 3,但我不知道该怎么做。我有这个代码:

if ($this->input->post('adminImage') == null){
    $data['image'] = base_url('assets/images/default_avatar.png');
} else {
    $config['upload_path'] = './assets/images/admins';
    $config['allowed_types'] = 'gif|jpg|png|jpeg';
    $config['max_size'] = 10240;
    $config['max_width'] = 512;
    $config['max_height'] = 512;
    $config['encrypt_name'] = TRUE;

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

    if ($this->upload->do_upload('adminImage')) {
        $uploadData = $this->upload->data();
        $data['image'] = base_url('assets/images/admins/' . $uploadData['file_name']);
    } else {
        $_SESSION['messageDangerSm'] = $this->upload->display_errors();
        redirect(base_url('panel/admins'));
    }
}

如果我不选择图像,它会工作,将先前定义的 link 与图像一起发送到数据库。但问题是,即使我选择了一张图片,它仍然会向数据库发送一个 link 和默认图片,而不是用户选择的图片。如何修复它,以便在选择图像后将带有图像的 link 发送到数据库,如果您不选择此默认图像?预先感谢您的帮助:)

抱歉我的英语不好 xD

发送到数据库的代码部分在哪里?

 if (!empty($_FILES['file']['name'])) {

    $config['upload_path'] = './assets/images/admins';
    $config['allowed_types'] = 'gif|jpg|png|jpeg';
    $config['max_size'] = 10240;
    $config['max_width'] = 512;
    $config['max_height'] = 512;
    $config['encrypt_name'] = TRUE;

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

    if ($this->upload->do_upload('file')) {
    $uploadData = $this->upload->data(file_name);

    // now you need to send this to your model and upload to you db
    }
    else {
        $_SESSION['messageDangerSm'] = $this->upload->display_errors();
        redirect(base_url('panel/admins'));
    }