This question is borrowed from the same question, beacuse i faced same problem.During image posting in server side, image details could not getting in server side. Like this:
Failed to post image file information php server, userid ok but image file information could not post.In this case, Image save successfully on server, i could not get information on php sever of image.
Here is the Code:
public class UploadImageHttpPost {
String testpath="/mnt/sdcard/14111.jpg"; String url = "http://andtuts.com/uploadImage.php"; public static void sendPost(String url, String imagePath,String userId) throws IOException, ClientProtocolException { String responseBody; MultipartEntity entity = new MultipartEntity( HttpMultipartMode.BROWSER_COMPATIBLE); File file = new File(imagePath); FileBody encFile = new FileBody(file,"image/jpeg"); entity.addPart("images", encFile); entity.addPart("UserId", new StringBody(userId)); HttpPost request = new HttpPost(url); request.setEntity(entity); HttpClient client = new DefaultHttpClient(); ResponseHandler<String> responsehandler = new BasicResponseHandler(); responseBody = client.execute(request, responsehandler); if (responseBody != null && responseBody.length() > 0) { Log.w("TAG", "Response from image upload->" + responseBody); } } I get Like this:
Array ( [UserId] => 1 ) where i using this in php for testing , what cames from multipart:
$filedata = $_FILES['images'];
$f = fopen(time().".txt",'wb');
fwrite($f, print_r($_REQUEST,true));
fclose($f);
But here below part missing means i am not getting, is there any missing code in multipart post method please check above java code:
[images] => Array ( [name] => ball.png [type] => image/png [tmp_name] => /tmp/phpiQHIXQ [error] => 0 [size] => 1664972 ) I following this tutorials also: [http://www.webspeaks.in/2012/08/upload-files-from-android-to-server.html][2]
[2]: http://www.webspeaks.in/2012/08/upload-files-from-android-to-server.html and lots of other from the googled, but could not find proper solution.