hello,
Here is the code of my program "imgputdb.php"
thanks for help ;-)
<?
if ($action=="valider")
{
// sauvegarder l'image en base
// "$to" fichier cible
$date=0;
if ($to)
{
copy($to,"c:\temp\".$to_name);
echo " <br> copy $to c:\temp\$to_name <br>";
}
$purl_file=addslashes("$to");
$insert_file="LOAD_FILE(\"$purl_file\")";
$querytab = array();
$querytab[]="delete from tmp_etat_img where id_e=$id_session_cook and titre_img='$titre_img'";
$querytab[]="INSERT INTO tmp_etat_img
(id_img, id_e, titre_img, txt_img, img, name_img, type_img, usr_maj, date_maj)
VALUES
('', $id_session_cook, '$titre_img', '$txt_img', $insert_file, '$to_name', '$to_type', '$auteur', '$date')";
$taille=count($querytab);
$mesg="<br><hr>";
for ($index=0 ; $index<$taille ; $index++)
{
$res=mysql_query($querytab[$index],$link);
if ($res)
{
$code="<font color=\"green\"><b> OK </b></font>";
}
else
{
$code="<font color=\"red\"><b> ERROR ! </b></font>";
}
$mesg.="<br>query = $querytab[$index] $code ";
}
$mesg.="<p><br> file_svr = $to";
$mesg.="<br> size = $to_size";
$mesg.="<br> type = $to_type";
$mesg.="<br> Name = $to_name";
$mesg.="<br> titre_img = $titre_img";
$id= mysql_insert_id($link);
$mesg.="<p>Cette objet porte l'ID: <b>$id</b>";
}//////// Fin if ($action = add)
//*********************************************************************************
// afficher l'image si elle existe
//******************************************************************************
$query="select from tmp_etat_img where id_e=$id_session_cook and titre_img='$titre_img'";
$res=mysql_query($query,$link);
while($val=mysql_fetch_array($res,$link))
{
$txt_img = $val['txt_img'];
$image = $val['img'];
$name_img =$val['name_img'];
}
$num=mysql_num_rows($res);
if ($num!=0)
{
echo " <img src=\"imgdbget.php?titre_img=$titre_img\" alt=\"$name_img\" > ";
}
else
{
echo "<b><font color='red'> Pas d'image </font></b><br>";
}
//**********************************************************************************
//<input name="to" type="file" VALUE="default" size="50,2" >
?>
<FORM ENCTYPE="multipart/form-data" action="<? echo "creer_img.php?titre_img=$titre_img"; ?>" METHOD="post" >
Description de l'image :<br>
<textarea cols=50 rows=3 name="txt_img" wrap=auto><? echo $txt_img ?></textarea>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">
<br>Url de l'image :<br>
<input name="to" type="file" VALUE="toto" size="50,2" >
<br>
<input type="hidden" name="action" value="valider">
<input type="submit" name="bt" value="Valider">
</form>
<?
echo "$mesg";
?>
</BODY>