How do you take an image (passed in as a Base64 encoded string) and save it to the server in Asp.Net C#?
asp.net-mvc, base64, c#, encoding, file
Solution
byte[] contents = Convert.FromBase64String(file);
System.IO.File.WriteAllBytes(Server.MapPath(fileName), contents);
Problem
I want to create a function like this... ``` [AcceptVerbs(HttpVerbs.Post)] public ActionResult SaveImage(string file, string fileName) { } ``` Where the file is the Base64 encoded string created from the image, and the fileName is the name I want to save it as. How can I use this encoded string to write the image to the server? Do I need to use `BinaryWriter` or `TextWriter` or some other one? And how do you decode the data to allow it to write to the server properly?