I am working on a database with genealogy data with images and used the following
$form_data_name' is the image
<?php
if ($submit) {
MYSQL_CONNECT("localhost","username","password");
mysql_select_db("database");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO binary_data (doctype, bin_data,filename,filesize,filetype) ".
"VALUES ('$doctype', '$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
MYSQL_CLOSE();
} else {
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
Document type / Document type <br>
<input type="text" name="doctype" size="10"> <br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<br>Bestand/File:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
This works for me