Thread: CSS and Forums
View Single Post
  #9 (permalink)  
Old October 9th, 2007, 03:01 PM
ViagraFalls ViagraFalls is offline
Friend of Wrox
 
Join Date: Sep 2003
Location: Copenhagen, , Denmark.
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

For those interested, I ended up solving my avatar picture issue by adding some more properties to the fileupload control.

I added one to indicate a MaxFileLength (default to 22 * 1024), and one to indicate ImagesOnly defaulting to true.

Then, after verifying the user did select a file to upload with a size bigger than 0, I added the following bit of code:

if (filUpload.PostedFile.ContentLength > MaxFileLength)
{
   lblFeedbackKO.Text = "File is too big! The maximum filesize is: " + MaxFileLength.ToString() + " kb";
   lblFeedbackKO.Visible = true;
   return;
}

if (PicturesOnly)
{
   if (filUpload.PostedFile.ContentType != "image/gif" ||
   filUpload.PostedFile.ContentType != "image/jpg" ||
   filUpload.PostedFile.ContentType != "image/jpeg")
   {
      lblFeedbackKO.Text = "Images only, please!";
      lblFeedbackKO.Visible = true;
      return;
   }
}

and Bob's my uncle.

http://entropia-online.blogspot.com/