我想生成和發送創建的PDF到一個文件夾,但我得到一個錯誤,這個錯誤:保存生成的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的......,如果是AY STREAM = FALSE,它返回空白頁
$this->stream($filename.".pdf");
只需從命令寫入文件之前刪除$ this->即可。 file_put_contents()是一個本地PHP函數。 – Rooneyl
我已刪除$ this,現在出現新的連接錯誤 – alphy
該錯誤是由於在文件路徑中使用了http,因此您在路徑中使用了base_url()。結帳http://stackoverflow.com/questions/7490164/http-wrapper-does-not-support-writeable-connections-codeigniter-problem – Rooneyl