thinkphp6上传xlsx报错
文章描述:
thinkphp6上传xlsx文件报错,但是配置里面有xlsx文件
报错
“Could not find zip member zip://../public/storage/file/20240129/4f45772cb9a3bd0fea47dcd07db05ce6.xlsx#_rels/.rels”
这里判断了上传的是xls和xlsx
if($extension == 'xlsx'){
$objReader = IOFactory::createReader('Xlsx');
}else{
$objReader = IOFactory::createReader('Xls');
}
$objPHPExcel = $objReader->load($filenamex); // 传入的文件
$sheet = $objPHPExcel->getSheet(0); // excel中的第一张sheet
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数
需要在传入的文件前面加
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($filenamex);
$objReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
发布时间:2024/01/29
发表评论