2
By clicking a link, I wanted to download a file. The file path comes from the database. The file download path is correct, something like "catalogo/catalogo_janeiro.pdf".
<?php
$sql = mysql_query("SELECT * FROM tbl_catalogo WHERE id = '1'");
$row = mysql_fetch_array($sql);
$catalogo = $row['link']; // CAMINHO DO FICHEIRO
header("Content-disposition: attachment; filename=$catalogo");
header("Content-type: application/pdf");
readfile("$catalogo");
?>
The link to the download:
<a href="<?php echo $catalogo;?>" target="_blank"><img src="images/catalogo.jpg" /></a>
The problem is it gives me error in all header lines();
Warning: Cannot modify header information -
headers already sent by
(output started at /home/inforcyb/public_html/opaco/header.php:15)
in /home/inforcyb/public_html/opaco/index.php on line 181
What’s the matter?
– rray
Warning: Cannot Modify header information - headers already sent by (output Started at /home/inforcyb/public_html/opaque/header.php:15) in /home/inforcyb/public_html/opaque/index.php on line 181 Gives error on all header lines();
– pc_oc
This type of error happens when you have a texte output before a
header()
, sometimes this can be a problem in the enconding of the file that sends a character (GOOD) before the header– rray
I have already added the answer with resolution to my problem, thank you!
– pc_oc