【发布时间】:2014-07-16 04:43:28
【问题描述】:
如何从我的 android 应用程序中执行包含mkdir 命令的 php 文件?我尝试通过 this 链接使用 visudo 为我的 php 文件授予 root 权限,但它仍然不起作用。
但是,如果我从终端执行 php 文件,则会创建目录。那么我需要怎么做才能让我的 android 应用程序执行这个 php 文件呢?有什么想法吗?
下面是我的php文件:
<?php
$filename = $_POST['filename'];
mkdir("./xyz/".$filename);
?>
以及用于执行我的 php 文件的 Android 代码(核心代码):
if(method == "POST"){
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
【问题讨论】: