I'm working to develop simple Drag& Drop Multiple files uploader using Visual Studio 2013 and AjaxControlToolkit v15.0. I've got the AjaxFileUpload control but I notice that only one file appears as uploaded on the browser
Also, I see that OnUploadComplete event doesn't fire. I test the event by inserting an alert in the event and it does not run also the uploaded file is not shown in the project or database table.
This is my code :
.aspx file
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div align="center">
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" MaximumNumberOfFiles="10" OnUploadComplete="File_Upload" Width="500px" Mode="Auto" />
</div>
</form>
.aspx.cs file
protected void File_Upload(object sender, AjaxFileUploadEventArgs e)
{
SqlConnection con = new SqlConnection(abc);
try {
string filename = Path.GetFileName(e.FileName);
string strDestPath = Server.MapPath("~/Documents/");
SqlCommand cmd = new SqlCommand("INSERT INTO upload (name, path) VALUES(@FileName, @FilePath)");
cmd.Parameters.AddWithValue("@FileName", filename);
cmd.Parameters.AddWithValue("@FilePath", "Documents/" + filename);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
//Save file to project
AjaxFileUpload1.SaveAs(@strDestPath + filename);
}
catch (Exception er)
{
Response.Write("<script language='javascript'> alert(' problem');</script>");
}
finally { con.Close(); }
}
web.config
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<httpHandlers>
<add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</httpHandlers>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
</system.webServer>
Any solution ?