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
Post a Comment