MultipartEntity Android发送zip文件但无法将其保存在php中

时间:2014-09-19 19:19:14

标签: java php android post multipartentity

我使用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();

0 个答案:

没有答案