내 서버에 이미지를 업로드하는 중 지금 당장 잃어 버렸습니다. 사진을 찍어 Android 기기에서 내 위치 정보를 가져올 수 있습니다. 파일을 서버에 업로드 할 때 따르는 코드가 있습니다.이미지를 서버에 업로드 PHP Android
public Boolean postFunction(File image) {
String tag = "postFunction";
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(UPLOAD_URL);
try {
MultipartEntity entity = new MultipartEntity();
entity.addPart("type", new StringBody("photo"));
entity.addPart("data", new FileBody(image));
httppost.setEntity(entity);
HttpResponse response = httpclient.execute(httppost);
Log.i(tag, "picture was uploaded " + response.toString());
return true;
} catch (ClientProtocolException e) {
Log.e(tag, "Client: " + e.toString());
return false;
} catch (IOException e) {
Log.e(tag, "IO: " + e.toString());
return false;
}
}
이 기능에 이미지 파일을 전달하고 업로드합니다. 그러나 오류는 내가 믿는 서버 측에있다. 여전히
public function upload() {
//$type = $this->input->post('type');
//$data = $this->input->post('data');
$base = $_REQUEST['data'];
echo $base;
// base64 encoded utf-8 string
$binary = base64_decode($base);
// binary, utf-8 bytes
header('Content-Type: bitmap; charset=utf-8');
// print($binary);
//$theFile = base64_decode($image_data);
$file = fopen('./test.jpg', 'wb');
fwrite($file, $binary);
fclose($file);
echo '<img src=test.jpg>';
}
파일을 터치 도착하지만 아무 것도 표시되지 :
여기 내 PHP 코드입니다. 내가 여기서 뭔가를 놓치고 있니? 제발 도와주세요, 나는 인터넷 검색을 시도했지만 많이 도움이되지 않은 다른 결과가 떠올랐다.