Maybe something like this...

$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.


> -----Original Message-----
> From: Brandon [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, June 29, 2002 3:52 AM
> 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(.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to