Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code;
C#
foreach (HttpPostedFileBase file in files)
                {

                    System.Drawing.Image sourceimage = System.Drawing.Image.FromStream(file.InputStream);

..... its containing.
}


What I have tried:

This line I take error. I have tried memoryStream, Bitmap but this give me always same error.
Posted
Updated 29-Nov-20 5:35am
v2

1 solution

Most likely reason is that the stream does not contain a valid (or at least known) image.

Start by saving the file data, and look at exactly what the file contains. If it's binary data, that's a good sign. If it's human readable, then look at what the text says - it's probably important.

Binary data may or may not be a valid image file - System.Drawing.Image does not support .webp files for example - or the data may be corrupt. We can't tell because we have no access at all to your data!

So start with the data itself, and if that all looks ok (and you can view it as an image after saving the file) then start using the debugger to find out exactly what is going on.

Sorry, but we can't do any of that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900