【问题标题】:Storing MPDF Output in a Folder将 MPDF 输出存储在文件夹中
【发布时间】:2017-11-23 06:30:02
【问题描述】:

我需要将我的 PDF 输出保存在 CodeIgniter 中的一个文件夹中,我该怎么做我在下面给出的控制器,现在我的 MPdf 输出正在下载,但我需要显示并将其保存到一个文件夹中以供将来访问

我的控制器

class Pdf extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->library('M_pdf');
    }
    public function index() {
        //load view
        $this->load->model("crud_model");
        $data["fetch_data_seminar"] = $this->crud_model->fetch_data_seminar();
        $data1["fetch_data_conf"] = $this->crud_model->fetch_data_conf();
        $data2["fetch_data_extra"] = $this->crud_model->fetch_data_extra();
        $data3["fetch_data_cgpa"] = $this->crud_model->fetch_data_cgpa();
        $data4["fetch_data_representation"] = $this->crud_model->fetch_data_representation();
        $data5["fetch_data_participation"] = $this->crud_model->fetch_data_participation();
        $data6["fetch_data_organ"] = $this->crud_model->fetch_data_organ();
        $data7["fetch_data_events"] = $this->crud_model->fetch_data_events();
        $data8["fetch_data_program"] = $this->crud_model->fetch_data_program();
        $data_array = array(
            'seminar' => $data,
            'conf' => $data1,
            'extra' => $data2,
            'cgpa' => $data3,
            'representation' => $data4,
            'participation' => $data5,
            'organ' => $data6,
            'events' => $data7,
            'program' => $data8,
        );

        $showdata = [];
        $html = $this->load->view('makepdf', $data_array, TRUE);
        $pdfFilePath = "download.pdf";
        $this->m_pdf->pdf->WriteHTML($html);
        $this->m_pdf->pdf->Output(pdfFilePath . pdf, "D");
    }
    public function generatepdf() {

    }
}

【问题讨论】:

标签: php codeigniter mpdf


【解决方案1】:
$pdfFilePath = "download.pdf";

//save in folder
$this->m_pdf->pdf->Output("./your_folder_location/".$pdfFilePath, "F");

//download file
$this->m_pdf->pdf->Output($pdfFilePath, "D");

【讨论】:

  • 我需要下载文件并保存在根目录下,
  • 我已经在配置中设置了路径,现在它正在服务器中下载,但我需要在保存后查看文件?/
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-12
  • 1970-01-01
相关资源
最近更新 更多