admin管理员组文章数量:1388919
UI form code
<form action="{{ url('/chefsUpload') }}" method="POST" enctype="multipart/form-data">
@csrf
<h3 class="text-center mb-4">Chefs Information</h3>
<!-- Name -->
<div class="mb-3">
<label for="name" class="form-label">Chef Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter chef's name" required>
</div>
<!-- Speciality -->
<div class="mb-3">
<label for="speciality" class="form-label">Speciality</label>
<input type="text" class="form-control" id="speciality" name="speciality" placeholder="Enter speciality" required>
</div>
<!-- Image Upload -->
<div class="mb-3">
<label for="image" class="form-label">Image</label>
<input type="file" class="form-control" id="image" name="image" accept="image/*" required>
</div>
<!-- Submit Button -->
<div class="text-center">
<button type="submit" class="btn btn-primary px-4 py-2">
Save Chef
</button>
</div>
</form>
UserController Code function ChefUpload
public function storechef(request $request)
{
if($request->hasFile('image'))
{
$image = $request->file('image');
$imageName = time().'.'.$image->getClientOriginalExtension();
$image->move(public_path('chefsUpload'),$imageName);
Chefs::create([
'name'=>$request->name,
'speciality'=>$request->speciality,
'image'=>$imageName
]);
return redirect()->route('storechef')->with('success','Chefs Store Successfully');
}
}
Route Web Routes
use App\Http\Controllers\userController;
Route::post('/chefsUpload', [userController::class,'storechef']);
Error I am getting Not Found The requested resource /chefsUpload was not found on this server. on Route http://127.0.0.1:8000/chefsUpload
Help me Solve this error
UI form code
<form action="{{ url('/chefsUpload') }}" method="POST" enctype="multipart/form-data">
@csrf
<h3 class="text-center mb-4">Chefs Information</h3>
<!-- Name -->
<div class="mb-3">
<label for="name" class="form-label">Chef Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Enter chef's name" required>
</div>
<!-- Speciality -->
<div class="mb-3">
<label for="speciality" class="form-label">Speciality</label>
<input type="text" class="form-control" id="speciality" name="speciality" placeholder="Enter speciality" required>
</div>
<!-- Image Upload -->
<div class="mb-3">
<label for="image" class="form-label">Image</label>
<input type="file" class="form-control" id="image" name="image" accept="image/*" required>
</div>
<!-- Submit Button -->
<div class="text-center">
<button type="submit" class="btn btn-primary px-4 py-2">
Save Chef
</button>
</div>
</form>
UserController Code function ChefUpload
public function storechef(request $request)
{
if($request->hasFile('image'))
{
$image = $request->file('image');
$imageName = time().'.'.$image->getClientOriginalExtension();
$image->move(public_path('chefsUpload'),$imageName);
Chefs::create([
'name'=>$request->name,
'speciality'=>$request->speciality,
'image'=>$imageName
]);
return redirect()->route('storechef')->with('success','Chefs Store Successfully');
}
}
Route Web Routes
use App\Http\Controllers\userController;
Route::post('/chefsUpload', [userController::class,'storechef']);
Error I am getting Not Found The requested resource /chefsUpload was not found on this server. on Route http://127.0.0.1:8000/chefsUpload
Help me Solve this error
Share Improve this question asked Mar 16 at 19:08 Abrar ul HassanAbrar ul Hassan 13 bronze badges 2 |1 Answer
Reset to default 0try to clear route cache php artisan route:cache
本文标签: phpLaravel Route Not Found (404) for POST requestStack Overflow
版权声明:本文标题:php - Laravel Route Not Found (404) for POST request - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744588967a2614365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
php artisan route:list
, do you see "/chefsUpload"? If you see, is it has prefix like "/prefix/chefsUpload"? – Onur Uslu Commented Mar 17 at 14:46userController
with loweru
is not conventional, not sure if that would be the problem but try using upper caseU
. Laravel built-in authentication also has aUserController
, are you using that, any chance your controller is clashing? – Don't Panic Commented Mar 21 at 17:38