require ("../db_connect.php");
$MainSQL = "SELECT Imagen,Tipo_img,Nombre_img FROM fotos where Num_img = '$id'";
$res = mysql_query($MainSQL);
$row = mysql_fetch_array($res);
$data = $row[0];
$tipo = $row[1];
$name = $row[2];
header("Content-Type: ".$tipo."\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: ".strlen($data)."\n");
header("Content-Disposition: attachment; filename=$name");
print $data;
require ("../db_dconnect.php");
exit;