Hola a todos estoy tratando de descargar un pdf usando php pero me salta el siguiente error:
Warning: Cannot modify header information - headers already sent by (output started at /home/u232864974/public_html/partials/headers.php:115) in /home/u232864974/public_html/verdetalle.php on line 141
Warning: Cannot modify header information - headers already sent by (output started at /home/4544545/public_html/partials/headers.php:115) in /home/4544545/public_html/verdetalle.php on line 144
%PDF-1.4 %äüöß 2 0 obj <> stream x��[ˎ�6��Wx=@U,Y~���m �]��Yf5��* n6��#�IQ���t���V�m=�8<$��j���|oZ�o0�g�������������t�ul��\��u�uh���w|�?��ia��]�__~��W�,�7��P��i�I���^^?^�`S3��:7?7?��1����?n�����Z{7�ow���ֵ���
etcetera
Y este es el codigo que utilizo:
<table class="table-bordered table-striped">
<tr>
<th colspan="4">Tus subidas...<label><a href="index.php">upload new files...</a></label></th>
</tr>
<tr>
<td>File Name</td>
<td>File Type</td>
<td>File Size(KB)</td>
<td>View</td>
</tr>
<?php
$sql="SELECT * FROM uploads";
$query = $db->prepare($sql);
//$result->bindparam(':orden_de_compra', $orden_de_compra);
$query->execute();
while($row = $query->fetch(PDO::FETCH_ASSOC))
{
?>
<tr>
<td><?php echo $row['file'] ?></td>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['size'] ?></td>
<td><a href="<?php echo $dir; ?>facturas/<?php echo $row['file'] ?>" target="_blank">view file</a></td>
<td>
<?
$content = $dir . 'facturas/' . $row['file'];
header("Content-type:application/pdf");
// It will be called downloaded.pdf
header("Content-Disposition:attachment;filename='downloaded.pdf'");
// The PDF source is in original.pdf
readfile($content);
?>
</td>
</tr>
<?php
}
?>
</table>