gpt4 book ai didi

android - 通过Android将视频上传到php服务器

转载 作者:行者123 更新时间:2023-11-29 14:08:40 25 4
gpt4 key购买 nike

这是我将视频上传到服务器的操作:

电子邮件
gameId
资源
上传的文件

是必须发送的参数。 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();

最佳答案

检查以下链接,在这里我提到了将图像文件上传到服务器的代码,该代码如何适用于您想要的任何文件

Android httpclient file upload data corruption and timeout issues

关于android - 通过Android将视频上传到php服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5026068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com