I am validating a form using validate.min.js
plugin. All validations are working perfectly fine but problem arises when i try to attach a file there.
The data is sent over to server but not filename / type.
Form is as below:
<form class="form cmxform" method="post" id="customForm" enctype="multipart/form-data">
<div class="form-group">
<label class="sr-only">Name</label>
<input type="text" class="form-control" name="nam_cst"
id="nam_cst" placeholder="Enter Name.." required>
<span class="help-block" style="color:red"></span>
</div>
<input type="file" class="form-control" name="uplod_cst" id="uplod_cst" required />
</form>
Ajax used for this is as:
var serializedData = $(form).serialize();
$.ajax({
url: "customFormDesign",
type: "post",
data: serializedData ,
mimeType:"multipart/form-data",
});
With above request, name is sent as data but not file.
I tried using FORMDATA
with no success and it has risk of browser compatibilties. So, i am avoiding it.
I also tried the solution here but with no success.
Any ideas please as i want to take all this in one go and one form only and that too without omiting validation plugin.
I do not want to use FORMDATA