fopen(w +):无法打开流

时间:2017-06-06 07:19:47

标签: php html wkhtmltopdf

我目前正在创建一个可以更改值的报价。它需要PDF转换。

这个转换是使用wkhtmltopdf完成的,遗憾的是我使用的旧方法没有转换更改的值,这就是我的脚本被更改的原因。

然而,它在第7行失败了:

$fp = fopen('w+','/tmp/tmp.html');

完整的脚本:

<?php
try {
   $content = $_REQUEST['content'];
    if(!file_exists('/tmp') ){
       mkdir('/tmp', 0777);
    }
   $fp = fopen('w+','/tmp/tmp.html');
   if($fp){
     fwrite($fp, $content);
     fclose($fp);

     $filename = '/tmp/out_' . time() .'.pdf'; // output filename
     shell_exec('wkhtmltopdf /tmp/tmp.html ' . $filename);

     //then eventually ask user for download the result
     header("Content-type:application/pdf");

     // It will be called output.pdf
     header("Content-Disposition:attachment;filename='output.pdf'");

    readfile($filename);
  }else{
     echo 'html file could not be created';
  }
} catch (Exception $e) {
  echo 'exception: ',  $e->getMessage(), "\n";
}
//

我希望有人能告诉我自己做错了什么。 如果需要更多信息,请告诉我。

0 个答案:

没有答案