Here i try to upload a video file. I used File Upload and a button control. Here i could not insert the uploaded file into database.
Here my code is:
---------------------
protected void btnUpload_Click(object sender, EventArgs e)
{
BinaryReader br = new BinaryReader(FileUpload1.PostedFile.InputStream);
byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length);
SqlCommand cmd = new SqlCommand("insert into tblFiles(Name, ContentType, Data) values (@Name, @ContentType, @Data)",con);
cmd.Parameters.AddWithValue("@Name", Path.GetFileName(FileUpload1.PostedFile.FileName));
cmd.Parameters.AddWithValue("@ContentType", "video/mp4");
cmd.Parameters.AddWithValue("@Data", bytes);
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect(Request.Url.AbsoluteUri);
}
When i click the button(btnUpload) to insert into database, got this problem. any one can help me guys. Advance thanks..
The connection to localhost was interrupted.
Here are some suggestions:
- Reload this webpage later.
- Check your Internet connection. Restart any router, modem, or other network devices you may be using.
- Add Google Chrome as a permitted program in your firewall's or antivirus software's settings. If it is already a permitted program, try deleting it from the list of permitted programs and adding it again.
- If you use a proxy server, check your proxy settings or contact your network administrator to make sure the proxy server is working. If you don't believe you should be using a proxy server, adjust your proxy settings: Go to the Chrome menu >Settings > Show advanced settings... > Change proxy settings... > LAN Settings and deselect the "Use a proxy server for your LAN" checkbox.