上传路径在多个上传文件和图片上似乎无效

时间:2019-05-27 07:16:53

标签: image file codeigniter upload

我收到与

相同的错误
  

Array([lpj] =>   上载路径似乎无效。   )数组([lpj] =>数组([file_name] => lpjHIMASOS27052019140622aska-review-form-6(2).doc [upload_path] => ./dokumen/ [allowed_types] => pdf | doc | docx [max_size] = > 1000))

这是我的控制器

 $lpj = 'lpj'.$this->session->userdata('id_ukm').date('dmYHis').$_FILES["lpj"]['name'];
   $configlpj["lpj"]['file_name'] = $lpj;
   $configlpj["lpj"]['upload_path'] = './dokumen/';
    $configlpj["lpj"]['allowed_types'] = 'pdf|doc|docx'; //if your file is image
    $configlpj["lpj"]['max_size'] = '1000';
    $_FILES['lpj']['name'] = str_replace(' ','-',$_FILES['lpj']['name']);
    $this->load->library('upload', $configlpj, 'lpj');

    //Upload file sertifikat
    $sertifikat = $this->session->userdata('id_ukm').date('dmYHis') . str_replace(' ','-',$_FILES["sertifikat"]['name']);
    $configser["sertifikat"]['file_name'] = $sertifikat;
    $configser["sertifikat"]['upload_path'] = './image/';
    $configser["sertifikat"]['allowed_types'] = 'png|jpg|jpeg'; //if your file is dokumen
    $configser["sertifikat"]['max_size'] = '500';
    $this->load->library('upload', $configser, 'sertifikat');

    //Upload Foto Penyerahan Sertifikat/Penghargaan
    $penyerahan = $this->session->userdata('id_ukm').date('dmYHis') . str_replace(' ','-',$_FILES["penyerahan_penghargaan"]['name']);
    $configpen["penyerahan_penghargaan"]['file_name'] = $penyerahan;
    $configpen["penyerahan_penghargaan"]['upload_path'] = './image/';
    $configpen["penyerahan_penghargaan"]['allowed_types'] = 'png|jpg|jpeg'; //if your file is dokumen
    $configpen["penyerahan_penghargaan"]['max_size'] = '500';
    $this->load->library('upload', $configpen, 'penyerahan');

    $this->lpj->initialize($configlpj);
    $this->sertifikat->initialize($configser);
    $this->penyerahan->initialize($configpen);
    if (!$this->lpj->do_upload('lpj')) {
        $error = array('lpj' => $this->lpj->display_errors());
        print_r($error);
        print_r($configlpj);
    } elseif (!$this->upload->do_upload('sertifikat')) {
       $error = array('sertifikat' => $this->sertifikat->display_errors());
        print_r($error);
        print_r($configser);
    } elseif (!$this->upload->do_upload('penyerahan_penghargaan')){
       $error = array('penyerahan' => $this->penyerahan->display_errors());
        print_r($error);
        print_r($configpen);

sameone可以帮我吗?

1 个答案:

答案 0 :(得分:0)

尝试这样

$dir_path = FCPATH.'assets/dokumen';
if(!is_dir($dir_path )){
   mkdir($dir_path);
}
$configlpj["lpj"]['upload_path'] = $dir_path;