I do believe this code will do a trick you look for
<?php
if(!is_numeric($_GET['id'])) { // We validate parameter
echo 'Wrong parameter';
exit();
}
$oDb = new mysqli("ip","user","pass","databasename"); // Connecting to database
if($oDb->connect_errno) { // Check for an error
echo 'Error';
exit();
}
$oResult = $oDb->query('SELECT `pathOnServer`, `realFilename`
FROM --tablename--
WHERE id = '.(int)$_GET['id'].'
LIMIT 1'); // make query
if($oResult->num_rows != 1) {
echo 'No file found';
exit();
}
$oQuery = $oResult->fetch_object();
header('Content-disposition: attachment; filename='.$oQuery->realFilename); // put special headers
readfile($oQuery->pathOnServer.$oQuery->id); // put the file
?>
You could also add the header with filesize. Hope it will help you.