The code that works fine for me is:
<?php
include "../connect/connectdb.php";
$txtIdCaso = $_GET['WWW_id_caso'];
$sql = "SELECT * FROM caso_solicitud
WHERE id_caso = '".$txtIdCaso."'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
header('Content-Description: File Transfer');
header('Content-type: "'.$row['tipo_archivo'].'"');
header('Content-Disposition: attachment; filename="'.$row['nombre_archivo'].'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("Content-length: ".$row['longitud_archivo']);
while (@ob_end_clean()) {
// do nothing
}
die($row['doc_solicitud']);
?>
Hope that can help. I tested several types of formats and works fine.
Greetings.