Monday, July 21, 2008

Using Uploaded Pictures

The following makes sure a valid picture file was uploaded.

this.ctlUpload.HasFile == true;
this.ctlUpload.PostedFile.ContentType == "image/bmp";
this.ctlUpload.PostedFile.ContentType == "image/pjpeg";
this.ctlUpload.PostedFile.ContentType == "image/gif";
this.ctlUpload.PostedFile.ContentType == "image/x-png";

The uploaded picture can then be accessed with :

HttpPostedFile postedFile = this.ctlUpload.PostedFile;
Bitmap picture = new Bitmap(postedFile.InputStream);

No comments: