【问题标题】:The upload path does not appear to be valid on multiple upload file and image上传路径在多个上传文件和图像上似乎无效
【发布时间】:2019-10-12 18:04:11
【问题描述】:

我得到了同样的错误

数组 ([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);

有没有人可以帮帮我?

【问题讨论】:

  • 你的项目目录结构是什么?
  • localhost -simkadmawa --aplication --assets --dokumen --system
  • 我的意思是你试图保存文件的目录是在应用程序文件夹内部还是外部?
  • 在应用程序之外
  • 好像project_folder->assets->dokumen?

标签: image file codeigniter upload


【解决方案1】:

这样试试

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

【讨论】:

  • @DanisAli 出现文件夹,但结果是 Array ( [lpj] => 上传路径似乎无效。) Array ( [lpj] => Array ( [file_name] => lpjHIMASOS27052019143008aska -review-form-6(2).doc [upload_path] => C:\xampp\htdocs\simkadmawa\assets/dokumen [allowed_types] => pdf|doc|docx [max_size] => 1000 ) )
  • 然后在配置目录中将./dokumen 更改为FCPATH.'assets/dokumen' ..../ 只是引用根目录。你有几个文件夹了。
  • @adit 试试这个代码,如果发生任何其他错误,请告诉我们。
  • 我们得到相同的错误 Array ( [lpj] => 上传路径似乎无效。) Array ( [lpj] => Array ( [file_name] => lpjHIMASOS27052019144420aska-review-form -6(2).doc [upload_path] => C:\xampp\htdocs\simkadmawa\assets/dokumen [allowed_types] => pdf|doc|docx [max_size] => 1000 ) ) '我像 $configlpj[" lpj"]['upload_path'] = FCPATH.'assets/dokumen'; '
  • 我认为文件上传的配置被覆盖
猜你喜欢
  • 2013-05-17
  • 2011-12-28
  • 1970-01-01
  • 1970-01-01
  • 2018-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多