android使用Multipartentity将.txt文件上传到服务器

时间:2012-07-23 12:17:21

标签: android

我尝试使用MulitPartEntity上传文本文件但无法上传..我的代码在下面提到请帮助我..

 File file = new File("/sdcard/" + strEmailAddress + ".txt");
    HttpClient httpclient = new DefaultHttpClient();

                HttpPost httppost = new HttpPost(strUrl);


        MultipartEntity reqEntity = new MultipartEntity(
                    HttpMultipartMode.BROWSER_COMPATIBLE);

            if (file.exists()) {
                Helper.printLogD(" file is exist ");
            }
            FormBodyPart bodyPart = new FormBodyPart("userfile",
                    (ContentBody) file);


        reqEntity.addPart(bodyPart);


        httppost.setEntity(reqEntity);

HttpResponse response = httpclient.execute(httppost);

0 个答案:

没有答案