Vote count:
0
I have the code to send my picture in android to pc using multipart entity. but when it executes, it has an error in my android phone. Is there something wrong with my code that i've been using ?.
Thank you for answering.
DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
FileBody localFileBody = new FileBody(new File(this.picturePath), "mImageName");
HttpPost localHttpPost = new HttpPost("http://ift.tt/1CE4NIQ");
MultipartEntity localMultipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
try
{
Log.d("picturepath", this.picturePath);
localMultipartEntity.addPart("name", localFileBody);
localHttpPost.setEntity(localMultipartEntity);
HttpResponse localHttpResponse = localDefaultHttpClient.execute(localHttpPost);
System.out.println("responsecode" + localHttpResponse.getStatusLine().getStatusCode());
}
catch (Exception e)
{
Log.d("exception", e.toString());
}
My php Code is here
<?php
$imageStoreFolder = "C:\Users\PUBLIC.PUBLIC-PC\Desktop\eclipse\Thesis2"; // change this where image is uploaded
if(isset($_FILES) && count($_FILES)){
foreach($_FILES as $file){
$source = $file['tmp_name'];
$destination = $imageStoreFolder.$file['name'];
move_uploaded_file($source, $destination);
}
}
?>
asked 1 min ago
Sending picture from android to pc using httpmultipartentity
Aucun commentaire:
Enregistrer un commentaire