<form id="uploadForm" enctype="multipart/form-data" action="http://localhost:1337/ad/upload" method="post" name="uploadForm" novalidate>
<input type="file" name="userPhoto" id="userPhoto" />
<input type="submit" value="submit" id="uploadImage" />
</form>
This is my html form which accepts an image as file inout, the user can select an image file and then click submit. This works but the url of the current page changes to localhost:1337/ad/upload. I want the page to stay at the same url.
$("form#uploadForm").submit(function(event) {
event.preventDefault();
var formData = new FormData($(this)[0]);
var posting = $.post(url, formData);
})
I have tried this to send the form using jquery but i get an error : Uncaught Type error : Illegal Invocation
What data does the form submit when the type is multipart /formdata and how can we get this data on jQuery