1. Design a table as shown below.
2. Now inside the UploadComplete event handler, write the following code.
Namespaces
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;
Code
protected void OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
string fileName = Path.GetFileName(e.FileName);
AjaxFileUpload11.SaveAs(Server.MapPath("~/Uploads/" + fileName));
string strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
string strQuery = "insert into tblFiles (FileName, FilePath) values(@FileName, @FilePath)";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.AddWithValue("@FileName", fileName);
cmd.Parameters.AddWithValue("@FilePath", "Uploads/" + fileName);
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}