我想生成创建的 pdf 并将其发送到一个文件夹,但我收到一个错误,这个错误:
A PHP Error was encountered
Severity: Warning
Message: file_put_contents(http://localhost/NQCL1/workbooks/NDQA000000001/NDQA000000001.pdf) [function.file-put-contents]: failed to open stream: HTTP wrapper does not support writeable connections
Filename: libraries/Dompdf_lib.php
Line Number: 13
Dompdf_lib.php //库文件
class Dompdf_lib extends Dompdf{
function createPDF($html, $filename='', $stream=TRUE){
$this->load_html($html);
$this->render();
$this->set_paper('a4', 'potratit');
if ($stream) {
//$this->stream($filename.".pdf"); - This works just ok
file_put_contents(base_url().'workbooks/s'.$filename.'/'.$filename.".pdf", $this->output());
} else {
return $this->output();
}
}
}
coa.php //控制器
function generateCoaDraft($labref,$offset=0) {
// error_reporting(1);
$data['labref'] = $labref = $this->uri->segment(3);
$data['information'] = $this->getRequestInformation($labref);
$data['tests_requested'] = $this->getRequestedTests($labref);
$data['trd'] = $this->getRequestedTestsDisplay2($labref);
$data['compedia_specification'] = $this->getCOABody($labref);
$html = $this->load->view('coa_v', $data, true);
$this->dompdf_lib->createPDF($html, $labref);
}
如果我使用它而不是 file_put....,则此行工作正常,如果我说 STREAM=FALSE,它将返回空白页
$this->stream($filename.".pdf");