PHPexcel上传失败,无法读取文件XLS

时间:2018-08-10 11:11:46

标签: php upload phpexcel

我有这样的脚本,为什么文件无法升级并且总是在错误消息脚本上出错(在线)。也许我的脚本有问题...?  但这正在localhost上运行。

    $fileName = time().$_FILES['lampiran2']['name'];
    $config['upload_path'] = "./resources/dokumen/"; //buat folder dengan nama assets di root folder
    $config['file_name'] = $fileName;
    $config['allowed_types'] = 'xls|xlsx|csv';
    $config['max_size'] = 10000;

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

    $uploadnya=$this->upload->do_upload('lampiran2');

    if(!$uploadnya)
    $this->upload->display_errors();

    $media = $this->upload->data('lampiran2');
    $inputFileName = "./resources/dokumen/".$media['file_name'];

    try {
            $inputFileType = IOFactory::identify($inputFileName);
            $objReader = IOFactory::createReader($inputFileType);
            $objPHPExcel = $objReader->load($inputFileName);
        } catch(Exception $e) {


            die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
        }

0 个答案:

没有答案