JasonDBurke
Programmer
Hi,
I'm uploading documents to a server using this type. Documents that fall under 4MB in size upload fine. Anything larger throws a Page Not Found Error. Here is the code I am using. Any help would be awesome! Thanks in advance, Jason.
string theFileName = Path.GetFileName(selectedFile.PostedFile.FileName);
Stream s = selectedFile.PostedFile.InputStream;
BinaryReader br = new BinaryReader(s);
int documentBufferSize = selectedFile.PostedFile.ContentLength;
byte[] document = new byte[documentBufferSize];
br.Read(document,0,documentBufferSize);
SqlCommand comInsertRecord = new SqlCommand("insert into " + theTableName + "(Document,UserName,DateSubmitted,DocumentType,filecomment,FileName,FileSize)Values(@Document,@UserName,@DateSubmitted,@DocumentType,@FileComment,@FileName,@FileSize)", connInsertRecord);
comInsertRecord.Parameters.Add("@Document",SqlDbType.Image).Value = document;
comInsertRecord.Parameters.Add("@DateSubmitted",SqlDbType.DateTime).Value = DateTime.Now.ToString();
comInsertRecord.Parameters.Add("@DocumentType",SqlDbType.NVarChar,80).Value = theDocType; comInsertRecord.Parameters.Add("@FileComment",SqlDbType.NVarChar,255).Value = theFileComment.ToString(); comInsertRecord.Parameters.Add("@UserName",SqlDbType.NVarChar,50).Value = theUserName.ToString();
comInsertRecord.Parameters.Add("@FileName",SqlDbType.NVarChar,80).Value = theFileName.ToString();
comInsertRecord.Parameters.Add("@FileSize",SqlDbType.BigInt).Value = theFileSize.ToString();
connInsertRecord.Open(); // Open the connection
comInsertRecord.ExecuteNonQuery(); // Execute the query
connInsertRecord.Close(); // Close the connection
s.Close();
br.Close();
I'm uploading documents to a server using this type. Documents that fall under 4MB in size upload fine. Anything larger throws a Page Not Found Error. Here is the code I am using. Any help would be awesome! Thanks in advance, Jason.
string theFileName = Path.GetFileName(selectedFile.PostedFile.FileName);
Stream s = selectedFile.PostedFile.InputStream;
BinaryReader br = new BinaryReader(s);
int documentBufferSize = selectedFile.PostedFile.ContentLength;
byte[] document = new byte[documentBufferSize];
br.Read(document,0,documentBufferSize);
SqlCommand comInsertRecord = new SqlCommand("insert into " + theTableName + "(Document,UserName,DateSubmitted,DocumentType,filecomment,FileName,FileSize)Values(@Document,@UserName,@DateSubmitted,@DocumentType,@FileComment,@FileName,@FileSize)", connInsertRecord);
comInsertRecord.Parameters.Add("@Document",SqlDbType.Image).Value = document;
comInsertRecord.Parameters.Add("@DateSubmitted",SqlDbType.DateTime).Value = DateTime.Now.ToString();
comInsertRecord.Parameters.Add("@DocumentType",SqlDbType.NVarChar,80).Value = theDocType; comInsertRecord.Parameters.Add("@FileComment",SqlDbType.NVarChar,255).Value = theFileComment.ToString(); comInsertRecord.Parameters.Add("@UserName",SqlDbType.NVarChar,50).Value = theUserName.ToString();
comInsertRecord.Parameters.Add("@FileName",SqlDbType.NVarChar,80).Value = theFileName.ToString();
comInsertRecord.Parameters.Add("@FileSize",SqlDbType.BigInt).Value = theFileSize.ToString();
connInsertRecord.Open(); // Open the connection
comInsertRecord.ExecuteNonQuery(); // Execute the query
connInsertRecord.Close(); // Close the connection
s.Close();
br.Close();