Ok as @greenapps suggested (credit goes to him) I solved like this.
Well not entirly solved, because I have to decode the file content at server side and save it manually on server.
so I jsut added the file content to the BasicNameValuePair
that I already had:
String fileAsBase64 = Base64.encodeToString( convertToByteArray(mFile)
, Base64.DEFAULT);
mPostPairs.add(new BasicNameValuePair("filecontent", fileAsBase64));
And this is the method that converts it to byte array:
/**
* Reads a file and returns its content as byte array
* @param file file that should be returned as byte array
* @return byte[] array of bytes of the file
*/
public static byte[] convertTextFileToByteArray(File file) {
FileInputStream fileInputStream = null;
byte[] bFile = new byte[(int) file.length()];
try {
fileInputStream = new FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();
}catch(Exception e){
e.printStackTrace();
} finally {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}finally {
fileInputStream = null;
}
}
return bFile;
}
At the server side I do this:
$content = imap_base64 ($_POST["filecontent"]);
that takes care of decoding the content back to normal.
Hope this helps someone else too