My controller receives the uploaded image in the request object in this code:
[HttpPost] public string Upload() { string fileName = Request.Form["FileName"]; string description = Request.Form["Description"]; string image = Request.Form["Image"]; return fileName; }
The value of the image (at least the beginning of it) looks something like this:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEAYABgAAD/7gAOQWRvYmUAZAAAAAAB/...
I tried to convert using the following:
byte[] bImage = Convert.FromBase64String(image);
However, this gives a System.FormatException: "Input is not a valid Base-64 string because it contains a non-base 64 character, more than two padding characters, or an invalid character among padding characters."
I get the feeling that the problem is that at least the beginning of the line is not base64, but for everyone I know, it is not. Do I need to parse a string before decrypting it? Did I miss something completely different?
source share