开发者

to upload video to a php server through android

开发者 https://www.devze.com 2023-02-12 02:43 出处:网络
This is what I am doing to upload a video to a server: email gameId source uploadedfile are the parameters that have to be sent. email, gameId and source are string values,

This is what I am doing to upload a video to a server:

email

gameId

source

uploadedfile

are the parameters that have to be sent. email, gameId and source are string values, whereas uploadedfile is the filebody to be uploaded.

Running this code gives response error0.

 HttpClient client = new 开发者_运维知识库DefaultHttpClient();  
                 String postURL = GlobalConfig.url+"uploadBlogData.php";
                 HttpPost post = new HttpPost(postURL); 
                 FileBody bin = new FileBody(file);
                 MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);  

             reqEntity.addPart("email", new StringBody(GlobalConfig.pref.getString(GlobalConfig.KEY_User_Emailid,""), "text/plain", Charset.forName( "UTF-8")));
             reqEntity.addPart("gameId", new StringBody(GlobalConfig.pref.getString(
                    GlobalConfig.KEY_Game_Created_id,
                    ""), "text/plain", Charset.forName( "UTF-8")));
         reqEntity.addPart("source", new StringBody("phone", "text/plain", Charset.forName("UTF-8"))); 
         reqEntity.addPart("uploadfile", bin);
         post.setEntity(reqEntity);  
         HttpResponse response = client.execute(post);  

         Log.d("resP",GlobalConfig.getStringFromResponse(response));

         HttpEntity resEntity = response.getEntity();  
0

精彩评论

暂无评论...
验证码 换一张
取 消