을 초과하면 "파일 크기가 길이를 초과합니다"라는 오류가 발생합니다. 시스템에서 가능한 큰 파일 크기를 허용하도록 설정하는 방법. 파일은 데이터베이스에 저장되고 열 유형은 varbinary (max)입니다. 이 오류의 원인을 모르십시오!파일 크기가 파일 크기가 1.66MB 이상인 경우
코드는 다음과 같습니다 당신의 web.config 파일에서
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][email protected], [fileType][email protected], [type][email protected],[submissionDate][email protected], [filePath][email protected] where [class_id][email protected] AND [module_id][email protected] 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();
학생 ID에 매개 변수화 된 SQL을 사용하지 않는 이유는 무엇입니까? * everything *에 대한 매개 변수를 사용하십시오. (이는 문제와 관련이 없지만 절대적으로 수행해야합니다.) –
최대 요청 크기와 관련된 IIS 사이트의 구성을 확인하십시오. - http://ajaxuploader.com/large-file-upload-iis-asp- net.htm, ** 역시 Jon Skeet이 말한 것! ** –
데이터베이스는 파일 서버가 아닙니다. –