上传路径似乎无效".Codeigniter文件上传

Lal*_*lit 7 upload codeigniter file

        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'doc|docx';
        $config['max_size'] = '400';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';

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

    if ( ! $this->upload->do_upload())
    {
        $error = array('error' => $this->upload->display_errors());

        $this->load->view('upload_form', $error);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());

  $this->referral_model->postCVReferralInfo($m_id, $emp_id , $job_id, $name, $age , $gender,$country_id, $mobile, $email, $summary, $workExp, $education, $qualification, $offer, $sb_id);
    header('location:'.$this->config->base_url().'index.php/member/referSuccess');

    exit;



    } ` 
Run Code Online (Sandbox Code Playgroud)

如果我尝试上传doc文件,那么我收到此错误"上传路径似乎无效".我将路径替换为绝对路径,然后我也收到此错误.请建议我如何解决这个问题

Pri*_*pal 13

调用时通常会出现问题$this->load->library('upload', $config),可能是它没有加载配置设置,因此请在加载上传库后添加以下语句.

$this->upload->initialize($config);
Run Code Online (Sandbox Code Playgroud)


小智 6

同样的问题......解决了

$this->upload->initialize($config);
Run Code Online (Sandbox Code Playgroud)

最好不要使用.... BASE_URL in $CONFIG['UPLOAD_PATH']


Ahm*_*awy 0

将您的代码更改为此$config['upload_path'] = 'uploads';