我使用android-async-http将文件上传到 PHP 服务器:
AsyncHttpClient client = new AsyncHttpClient();
AsyncHttpResponseHandler httpResponseHandler = createHTTPResponseHandler();
File file =new File(filePath);
RequestParams params = new RequestParams();
params.put("data", file);
client.post(context, url, params, httpResponseHandler);
这工作正常与进步,
但是当我使用这些代码将文件上传到 .NET 服务器时它不起作用,我通过将文件放入 HttpEntity 来解决它,如下所示:
HttpEntity entity = new FileEntity(file, "multipart/form-data");
client.post(context, url, entity, "multipart/form-data", httpResponseHandler);
它工作得很好,没有任何进展,只是一次冲洗。
我需要在文件上传时显示进度。谢谢。