2
一个PHP服务器这是我在做什么的视频上传到服务器:上传视频,通过机器人
电子邮件
游戏编号
源
UploadedFile的
是参数必须发送。 email
,gameId
和source
是字符串值, 而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();
在这u必须提供的链接这个人是设置标题,而不需要设置标题。已经通过从同一个URL上的iPhone应用程序上传一个文件来检查这一点,而不需要设置PHP头部。实际上,我们需要在PHP服务器上提交类型文件类型的POST参数。 – user620903 2011-02-17 07:40:14