when the file size is 1.66 MB or bigger than that, an error occurred saying"file size exceed the length".How to enable the system to accept big file size as much as it can. the file saves in database and the column type is varbinary(max). Do not know what does cause this error!
The code is:
if (FileUpload1.HasFile)
{
if (ext.Equals(".pdf"))
{
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
string classNmae = ddClass.Text.Split('~')[0] + ddClass.Text.Split('1');
com.Parameters.Clear();
com.CommandText = "UPDATE [Marking] SET [fileName]=@fileName, [fileType]=@fileType, [type]=@typ,[submissionDate]=@sd, [filePath]=@fp where [class_id]=@cid AND [module_id]=@mid AND [student_id]= '" + Session["id"].ToString() + "'";
com.Parameters.Add("@cid", SqlDbType.VarChar).Value = ddClass.Text.Split('~')[0];
com.Parameters.Add("@mid", SqlDbType.VarChar).Value = ddClass.Text.Split('~')[1];
com.Parameters.Add("@fileName", SqlDbType.VarChar).Value = filename;
com.Parameters.Add("@fileType", SqlDbType.VarChar).Value = "application/pdf";
com.Parameters.Add("@typ", SqlDbType.VarChar).Value = txtType.Text;
com.Parameters.Add("@sd", SqlDbType.VarChar).Value = DateTime.Now;
com.Parameters.Add("@fp", SqlDbType.Binary).Value = bytes;
com.ExecuteNonQuery();