0

I can post only data or uploaded file with Jquery but I want to post them to same method same time.I searched alot but I could only find file upload.When I try I get "Illegal invocation" error. Here is my code can you help me please.

View:

       var upfile = document.getElementById('fileupload').files[0];

            $.post("/Home/JobApplicationSave", { fc: $("#JobForm").serializeObject(),
             fileUpload:upfile}, function (data) {
                if (data.Result== true) {
                    FancyAlerts1.show({ msg: 'Thank you' });
                }
                else
                {
                    FancyAlerts1.show({ msg: data.Error});
                }
            });

Controller:

   public ActionResult JobApplicationSave(FormCollection fc, HttpPostedFileBase fileUpload)
    {
     //some code
    }
Euphoria
  • 51
  • 1
  • 7
  • 1
    Take a look at [Jquery ajax form submit that contains files](http://stackoverflow.com/questions/34603739/jquery-ajax-form-submit-that-contains-files) – Shyju Jul 27 '16 at 20:21
  • 1
    @Shyju Thank you very much I was trying to do this for 6 hours it worked like a charm. – Euphoria Jul 27 '16 at 20:35
  • Refer also [how to append whole set of model to formdata and obtain it in MVC](http://stackoverflow.com/questions/29293637/how-to-append-whole-set-of-model-to-formdata-and-obtain-it-in-mvc/29293681#29293681) –  Jul 27 '16 at 22:18

0 Answers0