hello please someone will help me for upload base64 converted image how can i upload to server i am sharing my code
List<byte> rawBuffer = new List<byte>();
var contentUri = Android.Net.Uri.FromFile(_file);
using (System.IO.Stream stream = ContentResolver.OpenInputStream(contentUri))
{
byte[] buffer = new byte[4096];
int len = 0;
while ((len = stream.Read( buffer, 0, buffer.Length))> 0) {
rawBuffer.AddRange(buffer.Take(len));
}
}
string base64 = System.Convert.ToBase64String(rawBuffer.ToArray());
try
{
var webClient = new WebClient();
webClient.Headers[HttpRequestHeader.ContentType] = "binary/octet-stream";
webClient.Upload(new Uri("http://xxxx.com/upload.php"),base64);
} catch (Exception ex) {
Console.Write ("{0}", ex.Message);
}
and this is upload.php
<?php
$base = $_REQUEST['data'];
echo $base;
$binary = base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
$file = fopen("image/test.jpg', 'wb');
fwrite($file, $binary);
fclose($file);
echo '<img src=test.jpg>';
?>
please help me with code
Thanks