In my Laravel Project i import data from Excel (.CSV). When i upload small count data (15 or 10) its imported, but upload more than 200 data its return (1/1) MethodNotAllowedHttpException. i using Maatwebsite/Laravel-Excel package to upload Data.
Controller Code :
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');
}
How to fix this Issue
This error
MethodNotAllowedHttpException
can be triggered when you are trying to submit a form with amethod='POST'
to aRoute::get
or vice versa.Make sure that your route is correct and your form is using the appropriate method.