1

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

Community
  • 1
  • 1
Gags
  • 3,759
  • 8
  • 49
  • 96
  • I don't see where any of this has to do with the jQuery Validate plugin. Where is the relevant code for this? – Sparky Aug 13 '15 at 18:49
  • possible duplicate of [JQuery Validate input file type](http://stackoverflow.com/questions/20929355/jquery-validate-input-file-type) – Manoj Babu Balaraman Aug 13 '15 at 18:51
  • @sparky.. i only copied submit handler here.. rest for validations m using jquery valaidate plugin only – Gags Aug 14 '15 at 01:47

0 Answers0