file('file'); if(!$oFile){ return $this->error('请选择上传文件'); } Storage::disk('local')->put('text.csv',file_get_contents($oFile)); $url = storage_path().'/app/text.csv'; $file = fopen($url, 'r'); if(!$file) { return $this->error('文件打开错误'); } while ($data = fgetcsv($file)) { //每次读取CSV里面的一行内容 array_walk($data, function(&$item){ $item = mb_convert_encoding($item, "UTF-8", "GBK"); }); $list[] = $data; } fclose($file); foreach ($list as $k=>$v) { if($k == 0) continue; $data = [ 'department_1' => $v[0], 'department_2' => $v[1], 'name' => $v[2], 'alias' => $v[3], 'clinicalFeature' => $v[4], 'diagnosis' => $v[5], 'treatment' => $v[6], 'regularMedication' => $v[7], 'pathogenesis' => $v[8], 'inspection' => $v[9], 'relevantOperation' => $v[10], 'laboratoryInspection' => $v[11], 'icd' => $v[12], 'etiology' => $v[13], 'auxiliaryExamination' => $v[14], 'antidiastole' => $v[15], 'prognosis' => $v[16], 'complicationsOverview' => $v[17], 'epidemiology' => $v[18], 'precaution' => $v[19], 'symptom' => $v[20], 'examination' => $v[21] ]; XyZskDisease::query()->insert($data); } return $this->response()->success('Success message...')->refresh(); } public function form() { $this->file('file', '请选择文件'); } public function html() { return <<导入EXCEL HTML; } }