本文介绍了上传文件 - 安卓,以谷歌的App Engine(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的Andr​​oid应用程序,以谷歌的App Engine,我发布一个zip文件;还我张贴的字符串。当谷歌应用程序引擎的PHP脚本运行时,我倾倒了$ _FILES到日志中值的...

From my Android app to Google App Engine, I'm POSTing a zip file; also I'm POSTing a string. When Google App Engine PHP script runs, I dump the value of $_FILES to the Log by...

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

我也登录了字符串的值。该日志的字符串输出,但不具有$ _FILES甩输出。我读此链接,但这似乎涉及到网络。我的Andr​​oid code张贴文件如下...

I also Log the value of the string. The Log has the string output but doesn't have the $_FILES dumped output. I read THIS LINK, but this seems to pertain to Web. My Android code to POST the file is as follows...

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?

My question is, am I POSTing the .zip file correctly? How do I capture the files uploaded that are usually stored in $_FILES?

推荐答案

您可以使用直接的文件上传功能php55(见的).

You can use the direct file upload function in php55 (see https://gae-php-tips.appspot.com/2015/03/09/direct-file-uploads-for-php-5-5/).

这篇关于上传文件 - 安卓,以谷歌的App Engine(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 11:28