Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I am uploading 11 mb file its not playing in Browser while 2 mb file playing .
Help me how to fix this problem ..

What I have tried:

C#
namespace VideoGallery
{
    public partial class VideoGallery : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }

        private void BindGrid()
        {
            string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
            using (SqlConnection con = new SqlConnection(strConnString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "select Id, Name from tblVideo";
                    cmd.Connection = con;
                    con.Open();
                    DataList1.DataSource = cmd.ExecuteReader();
                    DataList1.DataBind();
                    con.Close();
                }
            }
        }

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            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(strConnString))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandText = "insert into [tblVideo](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();
                    }
                }
            }
            //Response.Redirect(Request.Url.AbsoluteUri);
        }
    }
}
Posted
Updated 1-Apr-16 2:03am
v3
Comments
Jochen Arndt 1-Apr-16 8:11am    
Which kind of database you are using?
Maybe there is a limit for the field size.
kumarravishankar 1-Apr-16 8:12am    
I am Using Sql Server 2012, and in database i am only saving the Url
Jochen Arndt 1-Apr-16 8:24am    
And what does these lines do?

byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length);
...
cmd.Parameters.AddWithValue("@Data", bytes);
kumarravishankar 1-Apr-16 23:53pm    
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VideoGallery.aspx.cs" Inherits="Gallery.VideoGallery" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="lblTitle" runat="server" Text="Title">
</td>
<td>
<asp:TextBox ID="txtTitle" runat="server">
</td>
</tr>
<tr>
<td>
<asp:Label ID="Description" runat="server" Text="Description">
</td>
<td>
<asp:TextBox ID="txtDescription" runat="server">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblUploadVideo" runat="server" Text="Upload">
</td>
<td>
<asp:FileUpload ID="uploadVideo" runat="server" />
</td>
<td>
<asp:Label ID="lblMsg" runat="server">
</td>
</tr>
<tr>
<td></td>
<td>
<p>OR</p>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblYouTubeUrl" runat="server" Text="YoutubeUrl">
</td>
<td>
<asp:TextBox ID="txtYoutubeUrl" runat="server">
</td>
</tr>
<tr></tr>
<tr>
<td></td>
<td></td>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
</td>

</tr>
</table>
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="images/loader.gif" alt="" />
</div>
<div>
<asp:DataList ID="DataList1" Visible="true" runat="server" AutoGenerateColumns="false"
RepeatColumns="2" CellSpacing="15">
<itemtemplate>

<%# Eval("Title") %>








<%# Eval("Description") %>




<script src="FlowPlayer/flowplayer-3.2.12.min.js" type="text/javascript"></script>
<script type="text/javascript">
flowplayer("a.player", "FlowPlayer/flowplayer-3.2.16.swf", {
plugins: {
pseudo: { url: "FlowPlayer/flowplayer.pseudostreaming-3.2.12.swf" }
},
clip: { provider: 'pseudo', autoPlay: false },
});
</script>
</div>

</div>
</form>
</body>
</html>
----------------------------------------------------------------------------------------------------
Nathan Minier 1-Apr-16 9:55am    
It would also help to see how you have the [tblVideo].[Data] column defined.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900