在PHP中调用exec()时缺少查询字符串

时间:2013-09-18 08:53:20

标签: php wkhtmltopdf

我正在尝试在链接中创建带有get参数的pdf。

我的执行官看起来像这样:

exec('/usr/bin/wkhtmltopdf "' . 'http://www.mysite.be/this/that/other/print?debug=true' . '" ' . $_SERVER['DOCUMENT_ROOT'] . '/pdffile/' . $strPdfName);

如果我手动转到URL,那很好。但每当我想执行它时,似乎参数被切断了。没有错误。有人有任何想法吗?

我一直在寻找几个小时。它变得越来越好......

感谢您对此进行调查!

2 个答案:

答案 0 :(得分:0)

你应该使用escapeshellarg

来转义你传递给exec的参数
$url = escapeshellarg('http://www.kriski.be/skireizen/stages/technische-stage/print?debug=true');
$file = escapeshellarg($_SERVER['DOCUMENT_ROOT'] . '/pdfs/' . $strPdfName);

exec("/usr/bin/wkhtmltopdf $url $file");

答案 1 :(得分:0)

我找到了..这不是查询参数没有通过..但是没有创建pdf。因为服务器上已经有pdf这个名字了,所以下载了旧模板..

罪魁祸首在于CSS:

   @font-face {
     font-family: "Calibri Webfont";
     src: url("http://www.mywebsite.be/temps/def/css/fonts/calibri-webfont.ttf");
     font-weight: normal;
     font-style: normal;
    }

还不确定为什么会重置PDF创建或为什么我没有收到错误,但这是另一回事。