Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialManpreet Wasan
2,739 PointsA generic error occurred in GDI+ while converting base64string to an image using webApi2
While converting base64string to an image using webAp12 on hosting server it showing exceptionMessage=A generic error occurred in GDI+.
My code for Base64 image upload is
using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(DriverImage))) { using (Bitmap bm2 = new Bitmap(ms)) { bm2.Save(HostingEnvironment.MapPath("~/images/"+ ".jpg")); filename = Path.GetFileName(1001+ ".jpg"); } }
1 Answer
Steven Parker
231,210 PointsAre your strings incomplete?
There's not enough code here for a complete analysis, but one thing that jumps out at me are the places where you are combining literals to produce strings. Unless something is missing, wouldn't you just write them as a single string?
For example: where you have this: "~/images/"+ ".jpg"
, why not just write this: "~/images/.jpg"
? But even joined together, that really does look like a filename component may be missing. It looks equally peculiar where you have: 1001 + ".jpg"
.