Java Post请求不发送文件

Java Post请求不发送文件,java,android,http-post,Java,Android,Http Post,我正在尝试发送一个包含文件的post请求。由于某种原因,我的文件无法发送。你知道为什么会这样吗 ** public String postReceipt(String token, String FilePath) throws ClientProtocolException, IOException { Log.i("postData receipt", FilePath); File image = new File(FilePath); HttpPost htt

我正在尝试发送一个包含文件的post请求。由于某种原因,我的文件无法发送。你知道为什么会这样吗

**  public String postReceipt(String token, String FilePath) throws ClientProtocolException, IOException { 
    Log.i("postData receipt", FilePath);
    File image = new File(FilePath);
    HttpPost httppost = new HttpPost(url);

    Log.i("image name", image.getName());

    MultipartEntity multipartEntity = new MultipartEntity();  
    multipartEntity.addPart("access_token", new StringBody(token));
    multipartEntity.addPart("receipt[image]", new FileBody(image));
    // multipartEntity.addPart("image", new FileBody(image)); -> 500

    multipartEntity.addPart("store[name]", new StringBody("Some Store"));        
    multipartEntity.addPart("store[street]", new StringBody("Backstr. 29")); 
    multipartEntity.addPart("store[zip]", new StringBody("12047"));        
    multipartEntity.addPart("store[city]", new StringBody("Hamburg")); 
    multipartEntity.addPart("store[country]", new StringBody("DE")); 

    httppost.setEntity(multipartEntity);
    HttpClient httpclient = new DefaultHttpClient(httpParameters);

    HttpResponse response = httpclient.execute(httppost);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    response.getEntity().writeTo(out);
    String responseString = out.toString();
    Log.i("postData receipt", response.getStatusLine().toString());
    Log.i("postData receipt", responseString);
    return "DONE";
}
*$data=数组 ( “访问令牌”=>“248628ECD334282828E6”, “收据[图像]”=>“@d:\a67ff68fb34113ac300af9dde46b8aec__2.jpg” );


**

您如何检查文件是否在后端发送?我不确定是否理解您的问题。我从API得到了一个“坏”的响应。仅供参考,我确信该文件存在于我这边,当我在日志中打印它时,我可以看到它的名称。首先,看到名称并不意味着什么——文件可能不存在。LogLat告诉你什么错误了吗?我肯定文件存在。我看不到任何错误。好的,您有访问API或it文档的权限吗?
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, $url); 
curl_setopt($curl, CURLOPT_VERBOSE, true); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
$result = curl_exec($curl); 
curl_close($curl);  
print_r($result); ***