<?php

if ($id_files) {

  include "open_db.inc";

  $sql = "SELECT bin_data, filetype, filename, filesize FROM tbl_Files WHERE id_files=$id_files";

  $result = @mysql_query($sql, $db);

  $data = @mysql_result($result, 0, "bin_data");

  $name = @mysql_result($result, 0, "filename");

  $size = @mysql_result($result, 0, "filesize");

  $type = @mysql_result($result, 0, "filetype");

  header("Content-type: $type");

  header("Content-length: $size");

  header("Content-Disposition: attachment; filename=$name");

  header("Content-Description: PHP Generated Data");

  echo $data;

}

?>