how to restrict size and restrict format of fileupload control in asp.net?
how its possible....??

Recommended Answers

here is a tutorial that restrict file type and length! :)

tutorial

Jump to Post

All 4 Replies

here is a tutorial that restrict file type and length! :)

tutorial

commented: very good, short and correct responses... +4

You have to use FileUpload.PostedFile properties.

int fileLen = FileUpload1.PostedFile.ContentLength;
string contentType=FileUpload1.PostedFile.ContentType;
...
if(fileLen>=1 && fileLen<=1024*1024)
{
  //
}
if(contentType=="image/jpeg")
 {
   //code
 }

thanks alot i got it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.