2011-02-17 100 views
2

一个PHP服务器这是我在做什么的视频上传到服务器:上传视频,通过机器人

电子邮件
游戏编号

UploadedFile的

是参数必须发送。 emailgameIdsource是字符串值, 而uploadedfile是要上传的文件体。

运行此代码给出了回应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

检查以下几条链接我提一个代码到一个图像文件上传到服务器,它适用于任何文件,无论你有多想

Android httpclient file upload data corruption and timeout issues

+0

在这u必须提供的链接这个人是设置标题,而不需要设置标题。已经通过从同一个URL上的iPhone应用程序上传一个文件来检查这一点,而不需要设置PHP头部。实际上,我们需要在PHP服务器上提交类型文件类型的POST参数。 – user620903 2011-02-17 07:40:14