[英]Upload File - Android to 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/ )。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.