So, I can successfully read the image file and transfer it back to my C # application, but I cannot decode it correctly.
I am returning JSON data as such (the json_encode function is not shown) via PHP:
$imgbinary = fread(fopen($filename, "r"), filesize($filename));
if ( strlen($imgbinary) > 0 ){
return array("success"=>true, "map"=>base64_encode($imgbinary));
}
Then in C # I use Newtonsoft.Json to decode the string (I can successfully read the success and properties of the map), but I cannot use base64 decoding to write the image to the file correctly (or to display).
I am doing this as such:
File.WriteAllText(System.Windows.Forms.Application.StartupPath + "\\MyDir\\" + FileName, Base64Decode(FileData));
public string Base64Decode(string data)
{
byte[] binary = Convert.FromBase64String(data);
return Encoding.Default.GetString(binary);
}
- ? - , , , . ( , , 33%, , , , ).
/ !