I'm uploading an image from my android to my web server. My web server is written in ASP.NET MVC.
I can upload my image with a HttpPost on the android and then using the following php code:
$base=$_REQUEST['image'];
$binary=base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
$file = fopen('App_Data/Image.jpg', 'wb');
fwrite($file, $binary);
fclose($file);
My question is, is it possible to convert this over to my ASP.NET MVC? I feel very limited using the php as I'm not sure how to do a number of things I would be able to do in ASP.NET.
I understand the Request method in ASP.NET but I'm unsure how to do the base64_decode part.
PS. For more information on the method used, see this link
Edit: Code for the android part
This part converts the bitmap and base64 encodes it
Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+"/saved_images/2013-04-10--11-51-33-AEST--Fingerprint.jpg");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want.
byte [] byte_arr = stream.toByteArray();
String image_str = Base64.encodeBytes(byte_arr);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("image",image_str));
This part does the post
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://myipaddress/Up/Upload");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);