PHP从页面执行命令行

时间:2015-05-05 21:31:57

标签: php browser safari wkhtmltopdf wsh

我有一段PHP代码,它将URL传递给名为wkhtmltopdf的插件,并使用webkit呈现页面的PDF。

我的代码在IE和Firefox中工作正常,这是我们使用的主要两个,但我们的一些高管使用Safari并且代码无法运行。

if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST'){

  // DEVELOPMENT CODE
  $newPDF = md5($qid . time()). '.pdf';
  $current = getcwd() . '\\exports\\';

  $WshShell = new COM("WScript.Shell");
  $WshShell->exec($current.'makeWKPDF.bat "'.$fileURL.'&ref=nomenu" '.$newPDF); 

  // had to add this because shell isnt waiting for the file to finish before continuning 
  sleep(10);

  // get the contents of the new PDF file 
  $pdf = file_get_contents($toolURL."exports/".$newPDF);

  // push the PDF File to the browser
  header('Content-type: application/pdf'); 
  header('Content-Disposition: attachment; filename="Initiative '.$intID.' Export.pdf"'); 

  // push the PDF to the browser
  echo $pdf;

  // delete the PDF 
  @unlink($current.$newPDF);
} 

我在这一点上的第一个也是唯一的猜测是Safari不支持我创建的new COM

任何人都可以确认是否是这种情况并且可以解决这个问题。一直在做一些研究而且找不到任何东西。

更新 我也发现这在IE8中也不起作用。我认为这两个问题都指向PHP如何创建COM对象,但我不确定另一种方法可以让它工作。

0 个答案:

没有答案
相关问题