how to upload file pdf from dompdf to database in codeingniter?

时间:2017-08-05 12:19:58

标签: php codeigniter dompdf

How can I upload file from dompdf to database?

If i have controller like this:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Sertifikat extends CI_Controller {

    public function Sertifikat_pdf(){

      $this->load->library('session');

      $this->load->model('model_users');

      $data['userData'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));  

      $this->load->library('pdf');
      ini_set('max_execution_time', 300);
      $this->pdf->setPaper('A4', 'landscape');
      $this->pdf->filename = "Sertifikat_magang.pdf";
      $this->pdf->load_view('view_sertifikat', $data);

    }
}

In that controller i just show file of pdf, but how can i upload the file of pdf to database?

1 个答案:

答案 0 :(得分:0)

这可能会成功

$dompdf->render();
$pdf = $dompdf->output();
$file_location = $_SERVER['DOCUMENT_ROOT']."App_folder_name/reports/".$pdf_name.".pdf";
file_put_contents($file_location,$pdf)

其中reports是文件夹名称,其中所有PDF都将保存为输出。