이미지 업로드 코드인데...
갤러리에서 이미지를 선택하면 서버로 보내기만 하면 되는 간단한 코드임..
컴파일 에러는 안나는데 실제로 전송이 안되네요.... 제발 살려주셈
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == TAKE_PICTURE){
if( data != null ){
//final Bundle extras = data.getExtras();
//Bitmap photo = extras.getParcelable("data");
Uri selPhotoUri = data.getData();
try{
Bitmap selPhoto = Images.Media.getBitmap(getContentResolver(),selPhotoUri);
Cursor c = getContentResolver().query(Uri.parse(selPhotoUri.toString()), null, null, null, null);
c.moveToFirst();
abPath = c.getString(c.getColumnIndex(MediaStore.MediaColumns.DATA));
setAbPath(abPath);
timeThread();
c.close();
if( selPhoto != null ){ // 가지고온 사진 데이터를 이미지 뷰에 보여 준다.
iv.setImageBitmap(selPhoto);
tv.setText(abPath.toString());
//signup_camera.setImageBitmap(photo);
//Uri currImageURI = data.getData();
//textView.setText("GALLERY : " + getRealPathFromURI(currImageURI));
}
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
}
}
}
super.onActivityResult(requestCode, resultCode, data);
}
public String getAbPath(){
return abPath;
}
public void timeThread() {
dialog = new ProgressDialog(this);
dialog = new ProgressDialog(this);
dialog.setTitle("Wait...");
dialog.setMessage("사진 전송 중");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
dialog.show();
new Thread(new Runnable() {
public void run() {
// TODO Auto-generated method stub
try {
fileupload();
} catch (Exception e) {
Log.e("error", e.getMessage(), e);
}
dialog.dismiss();
}
private void sleep(int i) {
// TODO Auto-generated method stub
}
}).start();
}
public void fileupload(){
try {
File file = new File(getAbPath());
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(urlString);
post.setHeader("Connection", "Keep-Alive");
post.setHeader("Accept-Charset", "euc-kr");
post.setHeader("ENCTYPE", "multipart/form-data");
FileBody bin = new FileBody(file);
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("MEM_image", bin);
post.setEntity(reqEntity);
HttpResponse resp>
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
Log.i("RESPONSE", EntityUtils.toString(resEntity));
}
} catch (Exception e) {
e.printStackTrace();
}
}
[remove] 가 아니라 data 입니다.. 옮겨쓰는 과정에서 이상하게 됐네 ㅠㅠ
48번라인 고치세요
으와// 무슨 48번라인요????