Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Determining the Dimensions of Uploaded Images in ASP.NET

HttpPostedFile fil = this.FileUpload1.PostedFile;
int nFileLen = fil.ContentLength;
System.IO.Stream filStm = fil.InputStream;
byte[] theFile = new byte[nFileLen];
filStm.Read(theFile, 0, nFileLen);

//get the file name
string filename = FileUpload1.PostedFile.FileName;
FileInfo file = new FileInfo(filename);

//get the image width and height
System.Drawing.Image UploadedImage =
System.Drawing.Image.FromStream(fil.InputStream);
if (UploadedImage.Width > 300 || UploadedImage.Height > 400)
{
lblMessage.Text = "Uploaded image size is too high please resize";
return;
}


//get content type
string contentType = fil.ContentType;

Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy

Website Design & Internet Marketing by Shivam