lundi 19 mai 2014

Java - conversion d'une image Bitmap en String et en l'enregistrant dans un serveur mySQL - Stack Overflow


My program takes a bitmap and converts it to a string, then saves that string in a myswl through php. I am not getting any response from my server which includes not getting an error.


Here is the JAVA portion:


    ByteArrayOutputStream bos = new ByteArrayOutputStream();
proPic.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] data = bos.toByteArray();
String image = Base64.encodeToString(data, Base64.DEFAULT);
entity.addPart("tag", new StringBody("register"));
entity.addPart("name", new StringBody(name));
entity.addPart("email", new StringBody(email));
entity.addPart("password", new StringBody(password));
entity.addPart("image", new StringBody(image));

Here is the php part:


$name = $_POST['name'];
$stringPic = $_POST['image'];
$email=$_POST['email'];
$password=$_POST['password'];
$profilePic=base64_decode($stringPic);


My program takes a bitmap and converts it to a string, then saves that string in a myswl through php. I am not getting any response from my server which includes not getting an error.


Here is the JAVA portion:


    ByteArrayOutputStream bos = new ByteArrayOutputStream();
proPic.compress(Bitmap.CompressFormat.JPEG, 100, bos);
byte[] data = bos.toByteArray();
String image = Base64.encodeToString(data, Base64.DEFAULT);
entity.addPart("tag", new StringBody("register"));
entity.addPart("name", new StringBody(name));
entity.addPart("email", new StringBody(email));
entity.addPart("password", new StringBody(password));
entity.addPart("image", new StringBody(image));

Here is the php part:


$name = $_POST['name'];
$stringPic = $_POST['image'];
$email=$_POST['email'];
$password=$_POST['password'];
$profilePic=base64_decode($stringPic);

0 commentaires:

Enregistrer un commentaire