First I am consverting user selected image to base 64 string then i am sending this image to php server, There i am not getting complete base64 string. I don't know whats the problem.
Here is code:-
File file = new File(imagepath);
//encodeImagetoString convert image to base64 string
encodeImagetoString();
//encodedString is a base64 string
String imageString= encodedString;
EditText text= (EditText) rootView.findViewById(R.id.editText2);
String shayaritext=text.getText().toString();
Spinner mySpinner=(Spinner) rootView.findViewById(R.id.spinner1);
String catValue = mySpinner.getSelectedItem().toString();
UserFunctions userFunction = new UserFunctions();
json = userFunction.uploadShayariData(shayariName,catValue,shayaritext, imageString);
uploadShayariData function:-
@SuppressWarnings({ "deprecation", "deprecation" })
public JSONObject uploadShayariData(String name,String catValue,String shayaritext,String image){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", shayariUpload));
params.add(new BasicNameValuePair("cat", catValue));
params.add(new BasicNameValuePair("title", name));
params.add(new BasicNameValuePair("data", shayaritext));
params.add(new BasicNameValuePair("image", image));
// getting JSON Object
JSONObject json = jsonParser.getJSONFromUrl(registerURL, params);
// return json
return json;
}
PHP code:-
$image3=$_POST['image'];
// Get file name posted from Android App
$filename = "a.png";
// Decode Image
$binary=base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
// Images will be saved under 'www/imgupload/uplodedimages' folder
$file = fopen('uploads/'.$filename, 'wb');
// Create File
fwrite($file, $binary);
fclose($file);