You are using an undeclared variable
. Unless you've declared that somewhere else, it will be
, so you will get a reference error. And if you have declared it somewhere else, it almost certainly doesn't contain the value you expect it to contain.
object, which doesn't contain a
property. So that won't work either.
And based on your markup,
, not an
Start by fixing your code:
<input type="file" id="employeepic" name="employeepic">
const fileUpload = document.getElementById("employeepic");
const files = fileUpload.files;
const fileData = new FormData();
If it still doesn't work, then check your browser's developer console for errors. If there are none, check the network requests tab to examine precisely what you are sending to the server.