【问题标题】:How to send multi parameter in form data while uploading a file to server on Android?在Android上将文件上传到服务器时如何在表单数据中发送多参数?
【发布时间】:2012-02-04 14:06:33
【问题描述】:

在将文件上传到 Android 上的服务器时,我需要在表单数据中发送 multi 参数。我用了这个code for uploading a files to server.这里我的疑问是如何在表单数据中发送多参数?

【问题讨论】:

  • 天哪,不要使用那个代码。请参阅herehere 等。

标签: java android file-upload multipartform-data


【解决方案1】:

您可能想要使用 Apache HTTP 客户端的东西。将所需值的List<NameValuePair> 放入UrlEncodedFormEntity,将其设置为HttpPost 实例中的实体,然后发布。

Apache HTTP Client JavaDocs for Android are here.

【讨论】:

  • @bharath 我以为你想发送表单数据。有一个ByteArrayEntity 和一个FileEntity,如果这是你想要发送的。如果您不一定想先将所有内容加载到内存中,请使用InputStreamEntity
猜你喜欢
  • 2015-01-05
  • 1970-01-01
  • 1970-01-01
  • 2015-03-09
  • 2011-07-16
  • 1970-01-01
  • 2013-02-12
  • 1970-01-01
  • 2013-03-22
相关资源
最近更新 更多