Yes, that should be possible.
Correct me if I'm wrong: what you wanna do is to fetch a file outside web_root or in db?
This does that with blobs from db, and is used linked in an img-tag:
function cleanId($text) {
$text = ereg_replace("[^[:digit:]]", "", $text);
return($text);
}
if($picture_id == "") $picture_id = 53; else $picture_id = cleanId($picture_id);
$zQuery = mysql_query("select file, file_type, picture_name from table where picture_id=$picture_id");
$pRow = mysql_fetch_array($zQuery);
header("Content-Type: $pRow[file_type]");
header("Content-Disposition: inline; filename=$pRow[picture_name]");
echo $pRow[file];
Now, if this should be used for other filetypes, and forced as a download, you would make a standalone script and perhaps make it pop up:
<?PHP
function cleanId($text) {
$text = ereg_replace("[^[:digit:]]", "", $text);
return($text);
}
if($id == "") $id = 0; else $id = cleanId($id);
if(!empty($id)) {
$zQuery = mysql_query("select file, file_type, file_name from table where id=$id");
$pRow = mysql_fetch_array($zQuery);
header("Content-Type: $pRow[file_type]");
header("Content-Disposition: attachment; filename=$pRow[file_name]");
echo $pRow[file];
}
?>
Just a suggestion, and you might wanna build on it a bit.
The same code-structure may be used for fetching files from outside web_root, but then you would want to take precautions about where the files may be dld'ed from.
knutm