Hi,
I use Microsoft SQLServer with PHP. I want to insert an image uploaded, into a table, field type image. I have a problem to insert a file into a table, and retrieve it (display an image).
To accomplish the insertion, I use the following:
$nom_file = $FILES['fichier']['name'];
$taille = $FILES['fichier']['size'];
$tmp = $FILES['fichier']['tmp_name'];
$type = $FILES['fichier']['type'];
$img_binaire = str_replace("'","''",file_get_contents ($_FILES['fichier']['tmp_name'])); //l'image en binaire
And to update the table:
$requete="update trs_machine_inter set id_intermodel ='$intermodel', user_id ='$user', machine_id ='$machine_id', img_type ='$type', filesize ='$taille',".
"dcreate ='$date_creation', photo ='$img_binaire',".
"where id_minter='$code_intervention'";
$resultat=mssql_query($requete,$idConnexion);
To display the image, Iuse in other file (image.php):
$requete="select id_minter, photo, img_type, filesize from trs_machine_inter where id_minter=".$id;
$resultat=mssql_query($requete,$idConnexion);
$enreg=mssql_fetch_array($resultat);
header("Content-type: ".$enreg[2]);
header("Content-length: ".$enreg[3]);
echo $enreg[1];
But, the image dont displayed.