我尝试使用wkhtmltopdf将html文件转换为pdf,当我从命令行使用它时,它工作正常,但是当我试图将它与php集成时,它就不能工作了。
<?php
echo exec('whoami');
$cd = "cd C:/www/genpdf";
exec($cd);
$command = "C:/Program Files (x86)/wkhtmltopdf/wkhtmltopdf -O landscape C:/www/genpdf/index-5.html C:/www/genpdf/index-5.pdf";
exec($command);
if (file_exists("C:/www/genpdf/index-5.pdf")) {
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="index-5.pdf"');
readfile("C:/www/genpdf/index-5.pdf");
}
else {
echo "error";
}?>
echo exec('whoami');给我看了nt authority\бЁбвҐ行
然后我在浏览器中得到error行,没有pdf文件。
怎么了?
发布于 2014-02-05 09:23:26
设置可以禁用,以从php脚本运行系统命令。所以请先核实一下。还尝试使用system命令来代替exec。
https://stackoverflow.com/questions/21572199
复制相似问题