无法让php exec()运行

时间:2013-01-29 01:00:00

标签: php pdftk

我正在尝试运行以下命令,但由于文件未生成,因此无法运行。我根本没有得到任何错误消息,当我在我的linux盒子上测试它时这个命令工作正常,但我正在我的网站上移动到运行xampp的Windows框,因为我几天没有互联网连接。所以我正在更改命令以使用Windows。我认为我的命令一定有错误,但由于我没有使用apache的经验,Windows上的php我希望别人可以发现错误,如果有的话。

$command = 'C:\\Program Files (x86)\\PDF Labs\\PDFtk Server\\bin\\pdftk.exe C:\\xampp\\htdocs\\lc712\\pdf\\TimeCard.pdf fill_form C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.fdf' . ' output C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.pdf flatten';
    exec($command);

这是最终的代码:

$command = '"C:\Program Files (x86)\PDF Labs\PDFtk Server\bin\pdftk.exe" C:\xampp\htdocs\pdf\TimeCard.pdf fill_form C:\xampp\htdocs\pdf\results\\' . $userName . '.fdf' . ' output C:\xampp\htdocs\pdf\results\\' . $userName . '.pdf flatten';
    exec($command);

1 个答案:

答案 0 :(得分:3)

C:\Program Files (x86)\PDF Labs\PDFtk Server\bin\pdftk.exe包含空格,因此Windows会尝试使用参数C:\ProgramFiles(x86)\PDFLabs\PDFtk执行Server\bin\pdftk.exe,...

尝试使用引号转义路径:

$command = '"C:\\Program Files (x86)\\PDF Labs\\PDFtk Server\\bin\\pdftk.exe" C:\\xampp\\htdocs\\lc712\\pdf\\TimeCard.pdf fill_form C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.fdf' . ' output C:\\xampp\\htdocs\\lc712\\pdf\\results\\' . $userName . '.pdf flatten';
exec($command);
相关问题