JQuery .post ajax method and html file posting

I used below JQuery method .post to submit a form. All of HTML form controls except HTML file's data is getting posted. So How to post HTML file data from JQuery .post method?

var f = $('#frmtest');
                var action = f.attr("action");
                var serializedForm = f.serialize();
                $.post(action, serializedForm,
                function() {
                    alert('test');
                });
Thanks
lastbattleAsked:
Who is Participating?
 
Shinesh PremrajanConnect With a Mentor Technical ManagerCommented:
you need to set the enc-type attribute of the form

  f.attr( "enctype", "multipart/form-data")  //for FF
 f.attr( "encoding", "multipart/form-data")  //for IE


Hope this helps
0
 
lastbattleAuthor Commented:
I already have enctype in the <form> tag.
0
 
Shinesh PremrajanConnect With a Mentor Technical ManagerCommented:
there is not only enctype but also there is a encoding, which make the things working in the IE.

Hope this helps...
0
All Courses

From novice to tech pro — start learning today.