c# - Xamarin.Forms upload image to server directory -


i have upload image application php web service tried code:

private void  upload(mediafile mediafile) {     try     {            byte[] data = readfully(mediafile.source);          var imagestream = new bytearraycontent(data);         imagestream.headers.contentdisposition = new contentdispositionheadervalue("attachment")         {             filename = guid.newguid() + ".png"         };          var multi = new multipartcontent();         multi.add(imagestream);         var client = new system.net.http.httpclient();         client.baseaddress = new uri("url");         var result = client.postasync("api/manageimage", multi).result;     }     catch (exception e)     {      }  } 

php:

<?php      $uploads_dir = 'image/'; //directory save file comes      client application.           if ($_files["file"]["error"] == upload_err_ok)            {               $tmp_name = $_files["file"]["tmp_name"];              $name = $_files["file"]["name"];             move_uploaded_file($tmp_name, "$uploads_dir/$name");        } ?> 

i take file xam.plugin.filepicker don't know how send , how recive image


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -