I'm setting up a job where I need to download the file in pdf
, however this file is saved in the database it is in base64
format.
My idea is to do when the comrade clicks on the line he does the download
, of the file.
I tried to look for something but I did not find anything that heals my doubts.
My table looks like this:
echo '<tr>'
. '<td><a class="ajax-link" href="ajax/gerapdf.php?id=' . $registro->DAT_PUBLIC_DOWNL . '">' . $registro->DAT_PUBLIC_DOWNL . '</a></td>'
. '<td>' . $registro->TXT_TITUL_DOWNL . '</td>'
. '<td>' . $registro->TXT_EXTEN_ARQUI . '</td>'
. '</tr>';
gerapdf.php
<?php
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='arquivo.pdf'");
include '../includes/suc_validacao.php';
include '../includes/conexao.php';
$id = !empty($_GET['id']) ? $_GET['id'] : 0;
$conexao = new ConexaoDatabase();
$sql = "SELECT BLO_PDFXX_ARQUI FROM DB_EGLISE.tbl_DOWNLOADS WHERE COD_IDENT_IGREJ = :igj and DAT_PUBLIC_DOWNL = :data";
$sqlVars = array();
$sqlVars[':igj'] = $suc->getCOD_IDENT_IGREJ();
$sqlVars[':data'] = $id;
$registros = $conexao->fetch($sql, $sqlVars);
echo base64_decode($registros->BLO_PDFXX_ARQUI);
The output was:
PDF BASE64 DOWNLOAD