1

当我做类似的事情时

exec("c:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe --footer-center as  http://bbc.co.uk c:\\test2.pdf",$output);

什么都没发生。文件存在且以下行返回 1。

echo file_exists("c:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe");

如果我改变它

 exec("d:\\wkhtmltopdf\\wkhtmltopdf.exe --footer-center as  http://bbc.co.uk c:\\test2.pdf",$output);

工作正常。可以修复吗?

4

2 回答 2

2

如果我没记错的话,当路径名或文件名中有空格时,您可以使用双引号。

例如:

exec('"c:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe" --footer-center as  http://bbc.co.uk c:\\test2.pdf',$output);
于 2013-05-10T08:25:01.363 回答
1

您需要引用可执行文件的路径或转义空格。任何一个:

exec("c:\\Program^ Files^ (x86)\\wkhtmltopdf\\wkhtmltopdf.exe --footer-center as  http://bbc.co.uk c:\\test2.pdf",$output);

或者

exec("\"c:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe\" --footer-center as  http://bbc.co.uk c:\\test2.pdf",$output);

将工作。

于 2013-05-10T08:20:44.483 回答