相关疑难解决方法(0)

在Android中发送POST数据

我对PHP,JavaScript和许多其他脚本语言很有经验,但我没有很多Java或Android的经验.

我正在寻找一种方法将POST数据发送到PHP脚本并显示结果.

php java android client-server httpconnection

275
推荐指数
11
解决办法
43万
查看次数

Android- POST多部分表单数据

我想发送包含电子邮件和姓名等视频和数据的多部分表单.以下是我的代码,它不起作用,没有来自服务器的响应

File file =new File(VideoPath);
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);

        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("Name", "LDGHT"));
            nameValuePairs.add(new BasicNameValuePair("Email", "hhh@example.com"));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            httppost.setEntity(new FileEntity(file, "video/mp4"));

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
Run Code Online (Sandbox Code Playgroud)

post android http http-post

16
推荐指数
2
解决办法
5万
查看次数

标签 统计

android ×2

client-server ×1

http ×1

http-post ×1

httpconnection ×1

java ×1

php ×1

post ×1