Validate Base64 Image in ASP.Net / C# -
i'm building asp.net mvc4 application allows user send image encoded base64 string via post request. how validate user input ensure base64 string indeed image , prevent user passing malicious data in post request? e.g. prevent external urls being injected.
i follow same approach in php example , try create image base64 encoded data. if data not valid image, expect image throw exception or @ least, null.
doing quick search, found example here on so shows several methods create image base64 encoded string.
assuming ms of type memorystream, suspect wrap either 1 of these methods try/catch:
new bitmap(ms)
or
mage.fromstream(ms);
Comments
Post a Comment