http://www.androidpub.com/451838

자료를 보고 제가 만든 어플에서
기본 갤러리 어플을 인텐트로 불러서
이미지 Uri를 알아내고

http://www.mail-archive.com/android-developers@googlegroups.com/msg66448.html

여기에서 Uri로부터 파일의 절대경로를 구하는 방법을 알아내고

http://blog.inculab.net/28

여기 글 밑에 소스코드 다운로드 받아서 웹서버에 upload.php 로 이미지를 전송하는데 까지는 성공했어요.

근데 이미지를 아이디(문자열) 이름으로 서버에저장을 해야하기에

이미지와 (아이디(mb_id))문자열 변수를 upload.php 파일로 동시에 전송하는 방법을 알고 싶습니다.

업로드에 사용된 소스코드는 다음과 같습니다..

부탁드립니다.. (--)(__) 꾸벅..

[이미지 업로드 소스]
public class UploadTest extends Activity {

    private Button mUploadBtn;
    private FileInputStream mFileInputStream = null;
    private URL connectUrl = null;
    private EditText mEdityEntry; 
    
    String lineEnd = "\r\n";
    String twoHyphens = "--";
    String boundary = "*****";    
    
    Intent intent;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.upload_test);
        
        mEdityEntry = (EditText)findViewById(R.id.edit_entry);
        
        intent = getIntent();
        mEdityEntry.setText(intent.getStringExtra("data_selPhotoUriPath"));
        
        mUploadBtn = (Button)findViewById(R.id.btn);
        mUploadBtn.setOnClickListener(new View.OnClickListener() {            
            public void onClick(View v) {
                // TODO Auto-generated method stub
                try {
                    mEdityEntry.setText("Uploading...");
                    String mFilePath = intent.getStringExtra("data_selPhotoUriPath");
                    //String mFilePath = "/sdcard/DCIM/Camera/photo001.jpg";
                    DoFileUpload(mFilePath);                    
                } catch (Exception e) {
                    // TODO: handle exception
                }
            }
        });
        
    }
    
    private void DoFileUpload(String filePath) throws IOException {
        Log.d("Test" , "file path = " + filePath);        
        HttpFileUpload("http://jumoni.com/upload.php", "", filePath);    
    }
    
    private void HttpFileUpload(String urlString, String params, String fileName) {
        try {
            
            mFileInputStream = new FileInputStream(fileName);            
            connectUrl = new URL(urlString);
            Log.d("Test", "mFileInputStream  is " + mFileInputStream);
            
            // open connection 
            HttpURLConnection conn = (HttpURLConnection)connectUrl.openConnection();            
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Connection", "Keep-Alive");
            conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
            
            // write data
            DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
            dos.writeBytes(twoHyphens + boundary + lineEnd);
            dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + fileName+"\"" + lineEnd);
            dos.writeBytes(lineEnd);
            
            int bytesAvailable = mFileInputStream.available();
            int maxBufferSize = 1024;
            int bufferSize = Math.min(bytesAvailable, maxBufferSize);
            
            byte[] buffer = new byte[bufferSize];
            int bytesRead = mFileInputStream.read(buffer, 0, bufferSize);
            
            Log.d("Test", "image byte is " + bytesRead);
            
            // read image
            while (bytesRead > 0) {
                dos.write(buffer, 0, bufferSize);
                bytesAvailable = mFileInputStream.available();
                bufferSize = Math.min(bytesAvailable, maxBufferSize);
                bytesRead = mFileInputStream.read(buffer, 0, bufferSize);
            }    
            
            dos.writeBytes(lineEnd);
            dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
            
            // close streams
            Log.e("Test" , "File is written");
            mFileInputStream.close();
            dos.flush(); // finish upload...            
            
            // get response
            int ch;
            InputStream is = conn.getInputStream();
            StringBuffer b =new StringBuffer();
            while( ( ch = is.read() ) != -1 ){
                b.append( (char)ch );
            }
            String s=b.toString(); 
            Log.e("Test", "result = " + s);
            mEdityEntry.setText(s);
            dos.close();            
            
        } catch (Exception e) {
            Log.d("Test", "exception " + e.getMessage());
            // TODO: handle exception
        }        
    }
}



공지사항 읽었습니다..