A modern approach without Jquery is to use the FileList object you get back from <input type="file">
when user selects a file(s) and then use Fetch to post the FileList wrapped around a FormData object.
// The input DOM element // <input type="file">
const inputElement = document.querySelector('input''input[type=file]');
// Listen for a file submit from user
inputElement.addEventListener('change', () => {
const data = new FormData();
data.append('file', inputElement.files[0]);
data.append('imageName', 'flower');
// PostYou can then post it to your server.
// Fetch can accept an object of type FormData on its body
fetch('/uploadImage', {
method: 'POST',
body: data
});
});