[Solved] how to send data from html form to php using ajax using upload also


function dataSubmit(formid){

       //alert(formid);
    //   $('.result').html('<p style="display:block; text-align:center;"><i class="fa fa-refresh fa-spin fa-fw" aria-hidden="true"></i><span class="sr-only">Process...</span> Processing</p>');
        var action = $(formid).attr('action');

        var fd = new FormData();
           var file_data = $('input[type="file"]')[0].files; // for multiple files
           for(var i = 0;i<file_data.length;i++){
               fd.append("file_"+i, file_data[i]);
           }
           var other_data = $('form').serializeArray();
           $.each(other_data,function(key,input){
               fd.append(input.name,input.value);
           });
           $.ajax({
               url: action,
               data: fd,
               contentType: false,
               processData: false,
               type: 'POST',
               success: function(data){
                   console.log(data);
                   var tag = 'Successfull';

                     if(data.indexOf(tag) != -1){
                         eagleToast(data, 5000,'green');
                     }
                     else
                     {
                         eagleToast(data, 5000,'red');
                     }
               }
           });

    }

i wish this code will work.

solved how to send data from html form to php using ajax using upload also