[solved] send dynamic images from single .php page
Posted: Thu Mar 03, 2005 5:08 pm
I have some image names saved on my db and I want people to be able to hit a single page on my site with a file id that associates to the image in the database and then have it return the image.
for example:
that will return the image associsated with fid of 34.
here's what I've got and it's not working...I've been bugging Feyd about this pretty much all afternoon...but he's feeding his cat now so thought I'd jump here and spread it around some more.
thx,
Burr
for example:
Code: Select all
<img src="http://www.mysite.com/myfolder/mypage.php?fid=34">here's what I've got and it's not working...I've been bugging Feyd about this pretty much all afternoon...but he's feeding his cat now so thought I'd jump here and spread it around some more.
any help is greatly appreciated...<?
require_once('includes/dbInteract.php');
tt_db_connect();
$fid = (isset($_POST['fid']) ? $_POST['fid'] : $_GET['fid']);
$qry = "select * from lp_files where id = ".$fid;
$getfile = mssql_query($qry);
if($gtfile = mssql_fetch_assoc($getfile)){
$isimg = getimagesize($gtfile['fileloc']);
$fsize = filesize($gtfile['fileloc']);
header("Content-type: {$isimg['mime']}");
header('Content-Disposition: attachment; filename='.$gtfile['fileloc']);
header('Content-length: '.$fsize);
}else{
$message = "There are no files for that file id";
}
?>
thx,
Burr