wesley 6 years ago
parent
commit
fbad0cbee2
1 changed files with 9 additions and 2 deletions
  1. 9 2
      app/Http/Controllers/Admin/Company/InfoController.php

+ 9 - 2
app/Http/Controllers/Admin/Company/InfoController.php

xqd
@@ -75,8 +75,15 @@ class InfoController extends Controller
      */
     public function import(Request $request)
     {
-        Excel::import(new CompanyInfoImport, request()->file('company_info'));
-        $this->showMessage('操作成功');
+        $fileName = request()->file('company_info')->getClientOriginalName();
+        $fileType = fileExt($fileName);
+        if($fileType == 'xls' || $fileType== 'xlsx'){
+            Excel::import(new CompanyInfoImport, request()->file('company_info'));
+            $this->showMessage('操作成功');
+        }else{
+            return $this->showWarning("请上传xls或者xlsx格式的Excel文件");
+        }
+
     }
 
     /***