Answer the question
In order to leave comments, you need to log in
Why doesn't the $request array in Laravel contain data from an ajax submitted form?
Good afternoon!
I need to upload a file and a couple of text fields from the page to the server. I made a form in HTML, I send it to the server via AJAX:
HTML:
var formData = new FormData();
var file = document.getElementById("fileToLoad");
formData.append("fileToLoad", file.files[0]);
formData.append('now', $('#dateToLoad').val());
formData.append('test', 'test');
$.ajax({
url: '/counters/indication/loadFile',
data: formData,
type: 'PUT',
contentType: false,
processData: false,
success: function(msg) {
console.log(msg);
}
});
public function loadFile(Request $request)
{
var_dump($request->test);
die();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question