1

作成した 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"); 
4

2 に答える 2

2

file_put_contentsはネイティブの PHP 関数なので、行を次のように変更します。

file_put_contents('workbooks/s'.$filename.'/'.$filename.".pdf", $this->output());

$this-> を先頭に追加することで、システムはクラス (存在しない) に属する関数を見つけようとしているため、エラーが発生します。

于 2013-05-21T06:37:43.367 に答える