上传文件-Android到Google App Engine(PHP)

从我的Android应用程序到Google App Engine,我正在发布一个zip文件;我也在发布一个字符串.当Google App Engine PHP脚本运行时,我将$_FILES的值转储到Log by …

ob_start();
var_dump($_FILES);
$result = ob_get_clean();
syslog(LOG_DEBUG, "VAR DUMP\n" . $result . "\n");

我还记录了字符串的值.日志具有字符串输出,但没有$_FILES转储输出.我读了THIS LINK,但这似乎与Web有关.我的POST文件的Android代码如下所示…

private void postExamplesZipToDrive(File file_zip){
    RequestParams request_params = new RequestParams();
    request_params.put("test", "Came thru");

    //
    try{ request_params.put("file_zip", file_zip); }
    catch(FileNotFoundException e){
        Log.e("postExamplesZipToDrive", "File not found");
        Toast.makeText(this, "Unable to upload.", Toast.LENGTH_SHORT).show();
        return;
    }

    AsyncHttpClient async_http_client = new AsyncHttpClient();

    async_http_client.post(UPLOAD_URL, request_params, new JsonHttpResponseHandler(){
         @Override
         public void onSuccess(int code_status, Header[] headers, JSONArray success) {
            Toast.makeText(getApplicationContext(), "" + code_status, Toast.LENGTH_SHORT).show();
            super.onSuccess(code_status, headers, success);
         }

         @Override
         public void onFailure(int code_status, Header[] headers, String string_response, Throwable throwable){
             Toast.makeText(getApplicationContext(), "" + code_status, Toast.LENGTH_SHORT).show();
             Log.e("onFailure", code_status + "\n" + string_response);
         }
    });
}

我的问题是,我是否正确发布.zip文件?如何捕获通常存储在$_FILES中的上传文件

解决方法:

您可以在PHP55中使用直接文件上传功能(请参阅https://gae-php-tips.appspot.com/2015/03/09/direct-file-uploads-for-php-5-5/).

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...