2
Good night,
I have a table in the database that registers files(pdf,img,png and etc...) called
billets:
CREATE TABLE boletos (
protocolo int(11) NOT NULL AUTO_INCREMENT,
boleto mediumblob NOT NULL,
nomeBoleto varchar(20) DEFAULT NULL,
tipoBoleto varchar(20) DEFAULT NULL,
PRIMARY KEY (protocolo));
I was able to register in bytes[] of the files and pull from the bank and download, all the files download perfectly, only the pdf that does not download with its extension (.pdf), it downloads with the extension of (all the files) and I have to click on top to choose for it to open in pdf, someone knows why it happens only with pdf, my code is like this:
download php.:
<?php
include "config.php";
// Define o tempo máximo de execução em 0 para as conexões lentas
set_time_limit(100);
$GerParam=filter_input(INPUT_GET, "protocolo" ,FILTER_DEFAULT);
if(isset($_GET['protocolo'])){
$protocolo = $_GET['protocolo'];
$stat = $db->prepare("SELECT nomeBoleto,tipoBoleto,boleto FROM boletos WHERE protocolo=?");
$stat->execute(array($_GET['protocolo']));
$stat->bindColumn(1, $nomeBoleto, PDO::PARAM_STR, 256);
$stat->bindColumn(2, $tipoBoleto, PDO::PARAM_STR, 256);
$stat->bindColumn(3, $boleto, PDO::PARAM_LOB);
$stat->fetch(PDO::FETCH_BOUND);
header('Accept-Ranges: bytes');
header('Content-Transfer-Encoding: binary');
header("Content-Type: $tipoBoleto");
header("Content-Disposition: attachment; filename=$nomeBoleto");
echo $boleto;
}
?>
All download with the right extension only the pdf that does not...
It was perfect @Oliveira, just change the fieldName to Varchar(255) as you suggested, already solved the problem, mto thanks msm.. :)
– Joana