image file upload server help :(

BurakOgutkenBurakOgutken Burak OgutkenTRMember

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) {

string base64 = System.Convert.ToBase64String(rawBuffer.ToArray());
       var webClient = new WebClient();
       webClient.Headers[HttpRequestHeader.ContentType] = "binary/octet-stream";
       webClient.Upload(new Uri(""),base64);

 } catch (Exception ex) {
       Console.Write ("{0}", ex.Message);

and this is upload.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);
        echo '<img src=test.jpg>';

please help me with code


Sign In or Register to comment.