I cannot submit form information through to store function in laravel controller. I have even recreated the project, and redone the form - moving back into plain html as I suspect that the laravelCollective functions may be causing it but still the same error. I have even rearranged the the form attributes as suggested in another post/thread.
I have even recreated the project, and redone the form - moving back into plain html as I suspect that the laravelCollective functions may be causing it but still the same error. I have even rearranged the the form attributes as suggested in another post/thread.
The Form: < form method="POST" enctype="multipart/form-data" action="" accept-charset="UTF-8" > @method('PUT') @csrf ... // input fields here ... < /form >
The Routes: Route::resource('users/profile', 'ProfileController');
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('users', 'UserController'); Route::post('users/profile', 'ProfileController@store')->name('profile.store');
The ProfileController@store function: //some code omitted public function store(Request $request) {
$this->validate($request, [
'firstname'=>'required',
'lastname'=>'required',
...
'desc'=>'required'
]);
//handle file upload
if($request->hasFile('cover_image')) {
//Get file name with extension
$fileNameWithExt = $request->file('cover_image')->getClientOriginalName();
//Just file name
$fileName = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
//Just Ext
$ext = $request->file('cover_image')->getClientOriginalExtension();
//FileName to Store
$fileNameToStore = $fileName.'_'.time().'_'.$ext;
//upload image
$path = $request->file('cover_image')->storeAs('public/users/'.auth()->user()->id.'cover_images/'.$request->input('firstname').'_'.$request->input('lastname').'_'.auth()->user()->id.'/',$fileNameToStore);
} else {
$fileNameToStore = 'noimage.jpg';
}
/*
*/
$profile = new Profile;
$profile->firstname = $request->input('firstname');
$profile->lastname = $request->input('lastname');
...
$profile->desc = $request->input('desc');
$profile->save();
return redirect('/users/profile');//->with('success','Profile Created');
}
The famous error: Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException The PUT method is not supported for this route. Supported methods: GET, HEAD, POST.
Not sure what is causing the error, help appreciated.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/30akuJM
via IFTTT
Aucun commentaire:
Enregistrer un commentaire