note 25666 added to function.base64-encode

From: Date: Tue, 01 Oct 2002 22:00:47 +0000
Subject: note 25666 added to function.base64-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-37487@lists.php.net to get a copy of this message
You can use base64_encode to transfer image file into string text and then display them. I used this to store my images in a database and display them form there. First I open the files using fread, encoded the result, and stored that result in the database. Useful for creating random images. image.php: <? header(" Content-Type: image/jpeg"); header(" Content-Disposition: inline"); $sql = "SELECT data FROM image where name='".$img."'"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $image = $row[0]; echo base64_decode($image); ?> And in the html file you put: <img src="image.php?img=test3" border="0" alt=""> Guy Laor -- http://www.php.net/manual/en/function.base64-encode.php http://master.php.net/manage/user-notes.php?action=edit+25666 http://master.php.net/manage/user-notes.php?action=delete+25666 http://master.php.net/manage/user-notes.php?action=reject+25666

« previous php.notes (#37487) next »