【发布时间】:2012-06-13 12:42:54
【问题描述】:
我正在尝试写入 php 服务器上的 pdf 文件。我已将变量发送到服务器,创建 pdf 文档,然后让我的手机下载文档以在设备上查看。变量似乎没有写在 php 文件上。我在下面有我的代码
public void postData() {
try {
Calculate calc = new Calculate();
HttpClient mClient = new DefaultHttpClient();
StringBuilder sb=new StringBuilder("myurl.com/pdf.php");
HttpPost mpost = new HttpPost(sb.toString());
String value = "1234";
List nameValuepairs = new ArrayList(1);
nameValuepairs.add(new BasicNameValuePair("id",value));
mpost.setEntity(new UrlEncodedFormEntity(nameValuepairs));
} catch (UnsupportedEncodingException e) {
Log.w(" error ", e.toString());
} catch (Exception e) {
Log.w(" error ", e.toString());
}
}
还有我的 php 代码将变量“value”写入 pdf 文档:
//code to reverse the string
if($_POST[] != null) {
$reversed = strrev($_POST["value"]);
$this->SetFont('Arial','u',50);
$this->Text(52,68,$reversed);
}
我只是想把变量写在一个随机的地方,但是 if 语句总是为空,我不知道为什么。谢谢。有点草率见谅。
【问题讨论】: