RE: [PHP] Writing a GIF/JPG Image

From: Date: Tue, 02 Jul 2002 12:08:39 +0000
Subject: RE: [PHP] Writing a GIF/JPG Image
Groups: php.general 
Request: Send a blank email to php-general+get-104898@lists.php.net to get a copy of this message
Maybe something like this... <?php $filename = "Logo.gif"; $fd = fopen ($filename, "r"); $contents = fread ($fd, filesize ($filename)); fclose ($fd); $str_sql = "INSERT INTO mytable (myblob) VALUES ('$contents')"; $link = mysql_connect("localhost", "mysql_user", "mysql_password"); $dbselect = mysql_select_db("mydb", $link); $result = mysql_query($str_sql, $link); ?> If you are going to use this with different types of images you should probably store the content-type along with the image in the dB. /Joakim > -----Original Message----- > From: Brandon [mailto:brando@augmented-chaos.com] > Sent: Saturday, June 29, 2002 3:52 AM > To: php-general@lists.php.net > Subject: Re: [PHP] Writing a GIF/JPG Image > > > Well, hehe I'm kinda just learning it all, here is what I > really wanna do: > I have a table in a MySQL database that will contain the gif data in a > column. I want to be able to read that in with a SELECT > statement (which I > can do), problem is I need to actually put hte images in the > database, so I > need to somehow read in the Logo.gif file, and store it in SQL with an > INSERT statement... thats what Im trying to do, can't figure > it out 8(.

« previous php.general (#104898) next »