Laravel Excel导入 – MethodNotAllowedHttpException

在我的Laravel项目中,我从Excel(.CSV)导入数据。 当我上传小计数据(15或10),其导入,但上传超过200个数据,其返回(1/1) MethodNotAllowedHttpException 。 我使用Maatwebsite / Laravel-Excel包来上传数据。

控制器代码:

public function uploadleads(Request $request){ $usersid = Auth::user()->id; if($request->hasFile('leads')){ Excel::load($request->file('leads')->getRealPath(), function ($reader) use($usersid) { foreach ($reader->toArray() as $key => $row) { $data['name'] = ucfirst($row['candidatename']); $data['gender'] = ucfirst($row['gender']); $data['mobile'] = $row['mobileno']; $data['email'] = $row['email']; $data['work_experience'] = $row['workexperience']; $data['resume_title'] = $row['resumetitle']; $data['current_location'] = $row['currentlocation']; $data['preferred_location'] = $row['preferredlocation']; $data['current_employer'] = $row['currentemployer']; $data['current_designation'] = $row['currentdesignation']; $data['annual_salary'] = $row['annualsalary']; $data['ug_course'] = $row['ugcourse']; $data['pg_coruse'] = $row['pgcourse']; $data['post_pg_course'] = $row['postpgcourse']; $data['leads_address'] = $row['address']; $data['telephone'] = $row['telephone']; $data['dateofbirth'] = $row['dateofbirth']; $data['sourcefrom'] = $row['sourcefrom']; $data['created_by'] = $usersid; $baseleadscounts=Baseleads::Where('mobile',$row['mobileno'])->OrWhere('email',$row['email'])->count(); $templeadscount=Templeads::Where('mobile',$row['mobileno'])->OrWhere('email',$row['email'])->count(); if(($baseleadscounts + $templeadscount) > 0){ DB::table('duplileads')->insert($data); } else { if((preg_match('/(7|8|9)\d{9}/',$data['mobile'])) && ($row['gender'] == 'Male' || $row['gender'] == 'Female' || $row['gender'] == 'male' || $row['gender'] == 'female')){ DB::table('templeads')->insert($data); } else { DB::table('duplileads')->insert($data); } } } }); } alert()->success('Data Imported Successfully.', 'Success!'); return redirect('importreport'); } 

如何解决这个问题

当您尝试将method='POST'提交给Route::get或反之亦然时,可能会触发此错误MethodNotAllowedHttpException

确保您的路线是正确的,您的表单正在使用适当的方法。