Search code examples
c#asp.netfileuploadingallowmultiple

How to create BitMap from FileUpload AllowMultiple set to true?


I want to create a bitmap of each file in FileUpload, AllowMultiple set to True, but it's not working. In single file mode, I used to get bitmap from FileUpload.FileContent and it was OK.

foreach (HttpPostedFile file in flImage.PostedFiles)
{
    Bitmap originalBMP = new Bitmap(file);

Thanks for your kind help in advance!


Solution

  • Use file.InputStream instead of file:

    foreach (HttpPostedFile file in flImage.PostedFiles){
        Bitmap originalBMP = new Bitmap(file.InputStream);
    }