Bonjour,
svp j'ai deux pages php, l'une contient un formulaire avec des champs de type texte et de type file que je transmet par methode post à la deuxième page qui doit traiter les informations provenant du formulaire.
quand je valide mon formulaire la deuxième page m'affiche ceci
Notice: Undefined index: image in c:\program files\easyphp1-8\www\new-poly\administration\categories.php on line 10
Notice: Undefined index: image in c:\program files\easyphp1-8\www\new-poly\administration\categories.php on line 11
donc j'ai l'impression que les données du champs de type file ne sont pas transmis et je ne sais pas pourquoi ! ! !
voici la première page
***************************************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Document sans titre</title>
</head>
<body>
<table width="480" height="140" border="0" cellpadding="0">
<form name="categorie" method="post" action="categories.php">
<tr valign="top">
<td height="40" colspan="4" class="titreadd">Ajouter des catégories </td>
</tr>
<tr>
<td width="40" height="20" class="ajoutab"><div align="right">NOM:</div></td>
<td width="150"><input name="nom" type="text" id="nom"></td>
<td width="40" class="ajoutab"><div align="right">IMAGE:</div></td>
<td width="250"><div align="left">
<input name="image" type="file" id="image" size="30">
</div></td>
</tr>
<tr>
<td height="40" colspan="4"><input name="Reset" type="submit" id="Reset" value="Rétablir">
<input type="submit" name="Submit" value="Envoyer">
</td>
</tr>
</form>
</table>
</body>
</html>
***************************************************
voici la deuxième page 'categorie.php'
***************************************************
<?php
include('config.php');
if(isset($_POST['Submit']))
{
$nom = $_POST['nom'];
$image = $_FILES['image']['name'];
$type_file = $_FILES['image']['type'];
if(empty($nom))
{
echo"<script language='javascript'>";
echo"alert('Le nom de la catégorie est obligatoire !')";
echo"</script>";
}
else if(empty($image))
{
echo"<script language='javascript'>";
echo"alert('Le nom de l'image est obligatoire !')";
echo"</script>";
}
else if(!strstr($type_file,'jpg') && !strstr($type_file,'jpeg') && !strstr($type_file,'gif') && !strstr($type_file,'png') && !strstr($type_file,'bmp'))
{
echo"<script language='javascript'>";
echo"alert('Ce type d'image n'est pas accepté !')";
echo"</script>";
}
else
{
$req="INSERT INTO categories values('','','$image','$name',SYSDATE(),'')";
$resultat=mysql_query($req,$mysql_link) or die('Erreur SQL !'.$req.'<br>'.mysql_error());
echo"<script language='javascript'>";
echo"alert('Votre catégorie a été ajouter !')";
echo"</script>";
}
mysql_close();
/*
echo"<script language='javascript'>";
echo"history.go(-1)";
echo"</script>";
*/
}
?>
***************************************************
Configuration: Windows XP
Opera 9.26