note 38838 deleted from features.file-upload by nlopess

From: Date: Thu, 08 Jan 2004 16:09:43 +0000
Subject: note 38838 deleted from features.file-upload by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63153@lists.php.net to get a copy of this message
Note Submitter: jenei_gabor@drehsden.hu ---- If you have put an image into Mysql and want to get it to put onto a web page, here's a code for it so that you don't have to experiment. We have a database called "test" containing a table called "images" with columns "id", "mime", "data". Let's call this a "getimg.php": <?php $conn=mysql_connect(); mysql_query("use test"); $res=mysql_query("select * from images where id={$_GET['id']}"); $row= mysql_fetch_assoc($res); mysql_close($conn); header ("Content-length: ".strlen($row['data'])); header ("Content-type: {$row['mime']}"); echo $row['data']; ?> You can now display an image from the database by: <img src="getimg.php?id=1">

« previous php.notes (#63153) next »