public class FileUploadController : Controller { // // GET: /FileUpload/ string strcon = "server=ASMAA-PC;database=SignLanguage;integrated security=true"; [AcceptVerbs(HttpVerbs.Post)] public ActionResult FileUpload(HttpPostedFileBase FileUpload1) { using (BinaryReader br = new BinaryReader(FileUpload1.PostedFile.InputStream)) { byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length); // string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; using (SqlConnection con = new SqlConnection(strcon)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "insert into tblFiles(Video_name, ContentType, Data) values (@Name, @ContentType, @Data)"; cmd.Parameters.AddWithValue("@Name", Path.GetFileName(FileUpload1.PostedFile.FileName)); cmd.Parameters.AddWithValue("@ContentType", "video/mp4"); cmd.Parameters.AddWithValue("@Data", bytes); cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } } return View(); }
cmd.Parameters.AddWithValue("@Name", Path.GetFileName(FileUpload1.PostedFile.FileName));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)