i've been trying to store a video to my sql database with no success.
here is my FileUpload
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUploadVideo" runat="server" Text="Upload"
OnClick="btnUploadVideo_Click" />
<br />
Here is my btnUploadVideo_Click
protected void btnUploadVideo_Click(object sender, EventArgs e)
{
string filePath = FileUpload1.PostedFile.FileName;
string filename = Path.GetFileName(filePath);
string ext = Path.GetExtension(filename);
string contenttype = String.Empty;
switch (ext)
{
case ".avi":
contenttype = "video/avi";
break;
case ".mp4":
contenttype = "video/mp4";
break;
case ".wmv":
contenttype = "video/wmv";
break;
}
if (contenttype != String.Empty)
{
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
string strQuery = "insert into VIDEO(Video)" +
" values (@Video)";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.Add("@Video", SqlDbType.Binary).Value = bytes;
InsertUpdateData(cmd);
lblMessage.ForeColor = System.Drawing.Color.Green;
lblMessage.Text = "Video is Uploaded Successfully";
}
else
{
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "File format not recognised." +
" Upload Audio/avi/mp4/wmv formats";
}
}
on my Sql database, Video datatype is varbinary(MAX).
When i try to change the format from .avi to png or jpg it does store but video format it does not store. The error message is "The connection was reset"
The connection to the server was reset while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer's network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
I've also tried other browser it keep on giving me the same error