Upload file using $post jquery function

register

New Member
\[code\] $(".btnSavePurpose").click(function(e){ e.preventDefault(); var item=$(this); $.post("url", item.closest("form").serialize(), function(data){ if(data.Status=="Success") { //Let's replace the form with messsage alert("Updated Successfully"); } else { alert(data.ErrorMessage); } }); }); \[/code\]I want to post my form using ajax. I have used $post() jquery function. I am getting all data without file which is uploaded. I have added enctype to form. I am getting Request.File["file"] null. How I can retrive uploaded file\[code\]<form method="post" id="profile-form" enctype="multipart/form-data"> <table> <tr> <td style="width: 25%"> Profile Name<span class="Require">&nbsp;*</span> </td> <td style="width: 10%"> : </td> <td style="width: 70%">@Html.TextBoxFor(m => m.ProfileName, new { @class = "formTextBox" }) </td> </tr> <tr> <td> My Ocupation<span class="Require">&nbsp;*</span> </td> <td> : </td> <td>@Html.TextBoxFor(m => m.Ocupation, new { @class = "formTextBox" }) </td> </tr><tr> <td> Upload New Profile Photo </td> <td> : </td> <td> <input type="file" name="file" id="file" runat="server" accept="gif|jpg|png|jpeg|bmp" /> </td> </tr></table><input type="submit" id="btnSubmit" value="http://stackoverflow.com/questions/12581185/Submit" class="formButton" /></form>\[/code\]
 
Back
Top