Actually the image which is captured is shown in the form of Base64 string. Now i want to save that Base64 string Image to folder and its path to database on submit buttons click. for that i have tried like this
string x = prevImg1.ImageUrl;
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(x);
MemoryStream ms = new MemoryStream(imageBytes, 0,imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
image.Save("user_images/dailyLog/abc.png", System.Drawing.Imaging.ImageFormat.Png);
It is giving me this Error :
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength) at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength) at System.Convert.FromBase64String(String s) at DailyLog.SubmitBTN_OnClick(Object sender, EventArgs e) in e:\BSD\DailyLog.aspx.cs:line 889