[英]How to upload file pdf from dompdf to database in codeigniter?
How can I upload file from dompdf to database? 如何将文件从dompdf上传到数据库?
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? 在那个控制器中,我只显示pdf文件,但是如何将pdf文件上传到数据库?
This might do the trick 这可能会解决问题
$dompdf->render();
$pdf = $dompdf->output();
$file_location = $_SERVER['DOCUMENT_ROOT']."App_folder_name/reports/".$pdf_name.".pdf";
file_put_contents($file_location,$pdf)
where reports
is folder name where all PDF will be saved as output. reports
是文件夹名称,所有PDF将保存为输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.