I came across a scenario where I needed to update the logo path in my application. So, I defined a route like this:
Route::post('/updateLogo', 'CaptivePortalController@updateLogo');
After defining the route, I made a POST request as shown below:
$http({
method: 'POST',
url: '/updateLogo',
headers: { 'Content-Type': undefined },
transformRequest: function (data) {
console.log("data coming into the transform is ", data);
var formData = new FormData();
formData.append("company_logo_path", data.files);
console.log($scope.files.company_logo_path);
return formData;
},
data: { files: $scope.files.company_logo_path }
})
.then(function successCallback(response) {
console.log("success");
console.log(response);
$('.save-fade').delay(500).fadeOut(1000);
}, function errorCallback(response) {
console.log("fail");
console.log(response);
});
However, when I tried to upload the file and submit the form, I encountered an issue:
The network tab in Chrome Dev Tools showed a 405
error, indicating that a POST request was not allowed.
Upon further investigation, I discovered the error message:
MethodNotAllowedHttpException in RouteCollection.php line 218:
https://i.sstatic.net/FRyOR.png
I understand that I shouldn't be making a GET request to a POST route. However, I'm confused as to why it's being treated as a GET request instead of a POST. Any insights on what could be causing this issue?
Request URL:http://l.ssc.com:8888/en/updateLogo
Request Method:GET
Status Code:405 Method Not Allowed
Remote Address:127.0.0.1:8888
Referrer Policy:no-referrer-when-downgrade
Could anyone point out what mistake I might have made here?
Any suggestions or hints would be greatly appreciated. Thank you.