I have found this code....it load image in db but from a form with <input type="file" name="foto">
include ("db_init.php");
$data = addslashes(fread(fopen($foto, "r"), filesize($foto)));
$update="UPDATE annunciweb SET immaginefoto='$data',filetype='$foto_type' WHERE id=$lastid";
//$update="UPDATE annunciweb SET filetype='$foto_type' WHERE id=$lastid";
//echo "$update<br>";
$db_update=mysql_db_query($db_name,$update);
$up_ok=mysql_affected_rows();
//echo "up_ok=$up_ok<br>";
echo "FOTOTYPE=$foto_type<br>";
ok it works...
but i'd like to update images in db loaded from files , all called with extension imm (but always jpg)
tried with
include ("db_init.php");
$directory="foto/";
$foto="1.imm";
$data = fread(fopen("foto/".$foto, "r"), filesize("foto/".$foto));
//$foto_type=filetype($directory.$foto);
$foto_type="image/pjpeg";
echo "FOTOTYPE=$foto_type<br>";
//$data = addslashes(fread(fopen("foto/".$foto, "r"), filesize("foto/".$foto)));
$update="UPDATE annunciweb SET immaginefoto='$data',filetype='$foto_type' WHERE id=$lastid";
//$update="UPDATE annunciweb SET filetype='$foto_type' WHERE id=$lastid";
//echo "$update<br>";
$db_update=mysql_db_query($db_name,$update);
$up_ok=mysql_affected_rows();
echo "UP_OK=$up_ok<br>";
but it doesn't work, the field immaginefoto is a LONGBLOB
ALTER TABLE annunciweb ADD immaginefoto LONGBLOB;
ALTER TABLE annunciweb ADD filetype VARCHAR(50);