Bilawal Niaz

Bilawal Niaz

  • NA
  • 110
  • 16.4k

File upload not working....!

Jun 11 2016 5:54 AM
salam
 
file uploader send images in database when i not apply ajax,
 
but when i apply ajax than, file upload not  send the image into database.
any one tell me why? 
 
code is here:
 
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</asp:ScriptManager>
 
 
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
 
 <div>
<tr> <td>Image :</td> <td style="width: 235px">
&nbsp;<asp:FileUpload ID="FileUpload1" runat="server" CssClass="form-control" Height="40px" Width="220px" />
<br />
</td>
</tr>
</div> 
 
</ContentTemplate></asp:UpdatePanel> 
 
 
Backend coding is:
 
obj.Image = FileUpload1.FileName;
Random r = new Random();
long s = r.Next(10000, 200000);
obj.Image = s + FileUpload1.FileName;
string path = Server.MapPath(@"Images/" + s + FileUpload1.FileName);
FileUpload1.SaveAs(path);
 

Answers (6)