我试图按照答案THAT问题
但是,对于该代码,似乎默认的Android包中不包含类:
File file = new File("FileToSend.txt");
HttpClient client = new HttpClient();
String url = "http://www.yourdomain.com/destination.php";
PostMethod postMethod = new PostMethod(url);
Part[] parts = {new FilePart(file.getName(), file)};
postMethod.setParameter("name", "value"); // set parameters like this instead in separate call
postMethod.setRequestEntity( new MultipartRequestEntity(parts, postMethod.getParams()));
int status = client.executeMethod(postMethod);
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
Cannot instantiate the type HttpClient
FilePart cannot be resolved to a type XXXXX.java
MultipartRequestEntity cannot be resolved to a type XXXXX.java
Part cannot be resolved to a type XXXXX.java
PostMethod cannot be resolved to a type XXXXX.java
Run Code Online (Sandbox Code Playgroud)
如何解决这些错误,我必须添加一些库吗?如果是,请让我知道如何下载它.
HttpClient是(现在)一个界面.请DefaultHttpClient改用.这是您列出的其他一些替换课程:
FilePart - FileBody MultipartRequestEntity - MultipartEntity Part - ContentBody PostMethod - HttpPost
| 归档时间: |
|
| 查看次数: |
10420 次 |
| 最近记录: |