0

I am trying to upload an image from android to PHP file and then save it to server..

Here's the android code:

File image = new File(file_path);
try {
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://www.DomainName.com/imageUpload.php");
        MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        ContentBody cbFile = new FileBody(image, "image/jpeg");
        multipartEntity.addPart("image", cbFile);
        post.setEntity(multipartEntity);
        client.execute(post, new PhotoUploadResponseHandler());
        }
        catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.i("IOException", e.toString());
        }

PHP file

<?php
$uploadedFile = $_FILES['image']['name'];

$uploadedType = $_FILES['image']['type'];

$temp = $_FILES['image']['tmp_name'];

$error = $_FILES['image']['error'];

if ($error > 0) {
die("File could not be uploaded. $error");
}
else {
    move_uploaded_file($temp, "/Images/".$uploadedFile);
    echo "Upload Complete. ".$uploadedType;
}
 ?>

The problem i am facing, is that the output of this operation is "Upload Complete.", but there's no image in the specified path which is (/Images/) on the server!

Please help

Izzo32
  • 179
  • 1
  • 4
  • 16

0 Answers0