I'm using IIS 6.2
and my solution has a file-upload
control and trying to upload a bunch of images
but i get this error.I have searched the internet and got a lot of solutions but none of them worked.
I have applied maxAllowedContentLength="1073741824" but still get the same error.
protected void lnkbtnUpload_Click(object sender, EventArgs e)
{
try
{
foreach (HttpPostedFile objHttpPostedFile in fuUpload.PostedFiles)
{
string FileName = objHttpPostedFile.FileName;
string FileType = objHttpPostedFile.ContentType;
Stream fs = objHttpPostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
using (SqlConnection con = new SqlConnection(ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("uspInsertImage", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("Filename", SqlDbType.NVarChar).Value = FileName;
cmd.Parameters.Add("FileType", SqlDbType.NVarChar).Value = FileType;
cmd.Parameters.Add("ImageStream", SqlDbType.VarBinary).Value = bytes;
cmd.Parameters.Add("DateCreated", SqlDbType.DateTime).Value = DateTime.Now;
int i = cmd.ExecuteNonQuery();
con.Close();
}
BindImage();
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
My Web.Config File
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4073741824" />
</requestFiltering>
</security>