In order to upload either a new image in a new post or changing image in an old post, I have 2 routes that points to the same controller function in my web.php:
Route::post('/upload/{id}', 'UploadController@upload');
Route::post('/upload', 'UploadController@upload');
I have this in my UploadController:
public function upload($id = false, Request $request){
// code to upload an image to a new post OR to a post that already exists
}
this is the form action to upload image in a new post (which works fine):
<form class="bild" action="{{ URL::to('upload') }}" method="post" enctype="multipart/form-data">
this is the form action to upload image in an old post (which does not work):
<form class="bild" action="{{ action('UploadController@upload',$recept->id) }}" method="post" enctype="multipart/form-data">
Whenever I try to use the route upload/{id} i get the error MethodNotAllowedHttpException.
Can anyone see what I am doing wrong?