gpt4 book ai didi

php - 生产服务器上的 Laravel 5.2 方法不允许异常

转载 作者:搜寻专家 更新时间:2023-10-31 20:59:36 26 4
gpt4 key购买 nike

我在 laravel 中构建了一个简单的,它获取一些数据并将其存储在数据库中。

当我将我的代码上传到生产服务器时出现问题。在开发和本地它工作完美,但是当我尝试在生产服务器上提交相同的表单时它抛出以下异常:

MethodNotAllowedHttpException in RouteCollection.php line 218:

我已经检查了我的表单和路由方法,它们都已发布。我迷失了。

路线代码

Route::get('/', function () {
return view('welcome');
});
Route::group(['middleware' => ['web']], function () {
Route::get('auth/register', 'Auth\AuthController@register');
Route::post('/ajax-registration','RegistrationController@registration');
Route::post("/signup", "Api\ApplicantRegistrationController@registration");
Route::auth();

Route::get('/home', 'HomeController@index');
Route::get('/roles/{id}',"HomeController@roles");
Route::post('/complete-profile', 'HomeController@completeProfile');
});

Controller 代码(我从路由调用的函数)

public function completeProfile(Request $request){
If(Input::hasFile('file')){

$file = Input::file('file');
$cDate = date("d-m-Y_H:i:s");
$destinationPath = public_path(). '/uploads/';
$filename = $cDate."_".$file->getClientOriginalName();

$file->move($destinationPath, $filename);

}
$insert = DB::table('Applicant')->insert(
[
'name' => Auth::user()->name,
'email' => Auth::user()->email,
'total_experience' => $request->input('int_exp'),
'functional_area' => $request->input('txtFunctionalArea'),
'current_role' => $request->input('txtRole'),
'current_company' => $request->input('company'),
'desired_role' => $request->input('txtRole2'),
'file' => $filename
]);
\DB::table('users')->where('email', Auth::user()->email)->update(['allInformationReceived' => 1]);
if($insert){
return redirect('/home');
}
else{
return 'Some Error';
}
}

表单

<form id="signupform" method="POST" action="complete-profile" class="mob-pad0" enctype="multipart/form-data" style="padding: 20px 250px;">
<div class="col-md-6 col-xs-12 mob-pad0 padd-right60">
<div class="form-horizontal">
<div class="form-group">
<label for="int_exp">Total Experience</label>
<select class="form-control border-radius0" name="int_exp" id="int_exp" tabindex="2" required="required">
<option value="">Select</option>
Dropdown Using Ajax
<option value="15+">15+</option>
</select>
</div>
<div class="form-group">
<label for="txtFunctionalArea">Functional Area</label>
<select class="form-control border-radius0" name="txtFunctionalArea" id="txtFunctionalArea" tabindex="3" required="required">
<option value="">Select</option>
<option value="32">IT Software- Application Programming / Maintenance </option>
<option value="37">IT Software- Network Administration / Security </option>
</select>
</div>
<div class="form-group">
<label for="txtRole2">Desired Role</label>
<select class="form-control border-radius0" name="txtRole2" id="txtRole2" tabindex="6" required="required">
<option value="">Select</option>
Dropdown Using Ajax
</select>
</div>
</div>
</div>

<div class="col-md-6 col-xs-12 mob-pad0 padd-right60">
<div class="form-horizontal">
<div class="form-group">
<label for="company">Current Company</label>
<input name="company" id="company" type="text" placeholder="Current Company" class="form-control border-radius0" required="required" tabindex="5"/>
</div>
<div class="form-group">
<label for="txtRole">Current Role</label>
<select class="form-control border-radius0" name="txtRole" id="txtRole" tabindex="4" required="required">
<option value="">Select</option>
Dropdown Using Ajax
</select>
</div>
<div class="form-group">
<label for="resume">Resume (PDF/DOC)</label>
<input type="file" name="file" id="resume" class="form-control border-radius0" required="required" accept=".pdf,.doc, .docx" onchange="validate_fileupload(this);">
</div>
</div>
</div>
<input type="hidden" id="csrfToken" name="_token" value="{{ csrf_token() }}">
<div class="col-sm-12 col-xs-12 mob-pad0 text-center padd30">
<input type="submit" id="submitbtn_2" value="Get Started" class="inputButton btn btn-success"/>
</div>
</form>

任何帮助将不胜感激,谢谢。

最佳答案

感谢大家的投入,我在以下 URL 上找到了解决方案:

MethodNotAllowedException

并对我的代码进行了两处更改:

route 的一个,将方法更改为任意一个在表单中,将 post 方法更改为 PUT。

关于php - 生产服务器上的 Laravel 5.2 方法不允许异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46299614/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com