1
Reply

Check base64 string(image) type using C#

mari muthu

mari muthu

Jun 2 2017 9:43 AM
696
hi,
Actually my application i have the upload image functionality there i have passed one parameter(base64string) to my controller. here i want to check the base64string type . i tried one way but that was wrong if anybodys know please tell me that answer .
i need to change this line . how to check the type inside that string ,
<pre> string x = base64image.Replace("data:image/png|tiff|jpg|gif;base64,", "");</pre>
 
 
 
 
this is my code,
 
public bool LoadImage([FromBody]string base64image)
{
string x = base64image.Replace("data:image/png;base64,", "");
byte[] data = System.Convert.FromBase64String(x);
MemoryStream ms = new MemoryStream(data);
Image img = Image.FromStream(ms);
return false;
}
 

Answers (1)