Android 如何将文件发送到openhsift?

Android 如何将文件发送到openhsift?,android,openshift,Android,Openshift,我有一个Android应用程序,它将数据本地保存到一个文本文件(det.txt)。我还有一个在Openshift上使用PHP5.3的web应用程序。现在我需要将文本文件上传到Openshift上的web应用程序 以下是我用来上传文件的代码: try { String postReceiverUrl = "http://alldata-mylocation.rhcloud.com"; HttpClient httpClient = new DefaultHttpClient();

我有一个Android应用程序,它将数据本地保存到一个文本文件(det.txt)。我还有一个在Openshift上使用PHP5.3的web应用程序。现在我需要将文本文件上传到Openshift上的web应用程序

以下是我用来上传文件的代码:

try {
    String postReceiverUrl = "http://alldata-mylocation.rhcloud.com";

    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(postReceiverUrl);

    File file = new File(detail);

    FileBody fileBody = new FileBody(file);

    MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    reqEntity.addPart("file", fileBody);
    httpPost.setEntity(reqEntity);

    HttpResponse  response = httpClient.execute(httpPost);
    HttpEntity resEntity = response.getEntity();
}
下面是我推送到Openshift应用程序的php代码:

<?php
    if($_FILES) {
        $file = $_FILES['file'];
        $fileContents =  file_get_contents($file["tmp_name"]);
        print_r($fileContents);
    }
?>
这里有我遗漏的东西吗?或者我还应该做什么/用什么来完成这项工作

我很感激你的所有想法。我是Openshift的新手,所以请不要犹豫给我任何提示


谢谢。

您是否确保可以在web浏览器中看到您上传的页面?如果它在那里不起作用,那么当android尝试连接到它时,它也不会起作用。确保在上载代码时没有出现任何git推送错误。

问题出在php脚本代码中。谢谢你。@Xaver Kapeller非常感谢你的帮助。
String postReceiverUrl = "http://alldata-mylocation.rhcloud.com/alldata_receiver.php";