How do i allow a particular width and lenght of image file to be uploaded
400px * 500px
<asp:FileUpload onchange="ValidateSize(this)" runat="server" ID="FileUploadpost" />
<asp:LinkButton ID="LinkButton4" runat="server" CssClass="dropdown bg_none btn"/>
if (fup1.HasFile)
{
if (Array.IndexOf(new string[] { ".jpg", ".png" }, System.IO.Path.GetExtension(fup1.PostedFile.FileName).ToString().ToLower()) < 0)
{
return;
}
else
{
System.Drawing.Image img = System.Drawing.Image.FromStream(fup1.PostedFile.InputStream);
int height = img.Height;
int width = img.Width;
int size = fup1.PostedFile.ContentLength;
string dimension = width.ToString() + "*" + height.ToString();
if (size > 102400 && dimension != "700*350")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Insert image with dimension 700*350 and size less than 100MB.');", true);
}
}
}