You need to set file name and change "img" to "file" on line 6:
MultipartRequest cr = new MultipartRequest();
String filePath = Capture.capturePhoto(Display.getInstance().getDisplayWidth(), -1);
cr.setUrl(url);
cr.setPost(true);
String mime="image/jpeg";
cr.addData("file", filePath, mime);
cr.setFilename("file", "MyImage.jpg");//any unique name you want
InfiniteProgress prog = new InfiniteProgress();
Dialog dlg = prog.showInifiniteBlocking();
cr.setDisposeOnCompletion(dlg);
NetworkManager.getInstance().addToQueueAndWait(cr);
Then on php side, call the file name:
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 5000000) && in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
$named_array = array("Response" => array(array("Status" => "error")));
echo json_encode($named_array);
} else {
move_uploaded_file($_FILES["file"]["tmp_name"], "FolderPath/" . $_FILES["file"]["name"]);
$Path = $_FILES["file"]["name"];
$named_array = array("Response" => array(array("Status" => "ok")));
echo json_encode($named_array);
}
} else {
$named_array = array("Response" => array(array("Status" => "invalid")));
echo json_encode($named_array);
}
On a side note, always run Capture inside a try and catch. An exception would be thrown if user cancel the image capture or something else happened.