Inserting an Image into a Database?


Whats the best way to post an Image to a Database?
I’m able to get the image uploaded to the server, But its outputting and inserting that string into the Database, I have a databae setup called “Ideas” and the image will need to sit in that table

Code for upload of image is as follows :

<title>Simple file upload script</title>
if ($_REQUEST[completed] == 1) { 
       $source = "ideas/";
// Following code to fix line ends
       if (! eregi ('(gif|jpg|pdf)$',$_FILES['filename']['name'])) {
       $fi = file("$source".$_FILES['filename']['name']);
       $fi2 = fopen("$source".$_FILES['filename']['name'],"w");
       foreach ($fi as $lne) {
               $n = rtrim ($lne);
               fputs ($fi2,"$nn");
Your idea has been added.
<?php } else { ?>
<form enctype=multipart/form-data method=post>
<input type=hidden name=MAX_FILE_SIZE value=150000>
<input type=hidden name=completed value=1>
Ideas' Image: <input type=file name=filename><br>
<input type=submit value="Add Idea">
<?php  } ?>

But how do I insert that image string to the Database?


Here is a tutorial that will teach you how to

Sponsor our Newsletter | Privacy Policy | Terms of Service