我使用MulitpartEntity发送数据,我知道正在发送zip文件,我可以在php中循环它,但由于某种原因,类型返回空。
if($_FILES["imagezip"]["name"]) {
$type = $_FILES["imagezip"]["type"];
$strLog .= $type . " type\n";
}
当我试图移动它时它会继续失败
if(move_uploaded_file($_FILES['imagezip']['tmp_name'], $file_path)) {
$strLog .= "success\n";
} else{
$strLog .= "fail\n";
}
以下是我发送文件的方式
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url); // You can use get method too here if you use get at the php scripting side to receive any values.
MultipartEntity multipartEntity = new MultipartEntity();
multipartEntity.addPart("json", new StringBody(mPost));
multipartEntity.addPart("imagezip", new FileBody(mfile));
httpPost.setEntity(multipartEntity);
//httpPost.setEntity(new UrlEncodedFormEntity(parmeters));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream inputStream = httpEntity.getContent();