Formulaire avec upload d'image

Résolu/Fermé
Numters - 28 oct. 2013 à 18:15
 Numters - 28 oct. 2013 à 19:12
Bonjour,

Je suis entrain d'un peu m'amuser en php, de faire des test, ...
Je reste bloqué sur un gros problème, et sur ce coup si google ne veut pas être mon amis :)
Voici ce pourquoi je fait appel à vous :

J'ai réaliser un formulaire pour ajouter une news sur un site quelconque. Dans ce formulaire il y a des champ normaux (titre, texte, auteur, ...). J'ai crée un BDD pour les insérer dedans. Mais je voudrais également via ce formulaire ajouter des image dans un dossier que ce trouve à la racine de mes dossier (avec toute mes page html/php). Mon problème est le suivant, quand je clique sur envoyer mon formulaire la page deviens blanche et puis plus rien...
Je fonctionne avec Wamp

Voici mon code de "formulaire 1" :

<body class="bg"><!-- fond -->
<table width="100%">
<tr height="100px"> <!-- "contenu" -->
<td>

</td>
</tr>
<tr>
<td>
<table border="0" width="1000px" align="center"> <!-- contact-->
<tr>
<td align="right" width="100%">
 
</td>
</tr>
</table>
<!-- tableau intérieur-->
<table border="0" width="1000px" bgcolor="#ffffff" align="center">

<tr> <!-- ligne inutile haut -->
<td width="10px">
 
</td>
<td colspan="5">
 
</td>
<td width="10px">
 
</td>
</tr>

<tr>
<td>
 
</td>
<td height="50px" valign="top" colspan="5">
<img src="image/logo.png" width="40%" alt="logo"/>
</td>
<td width="10px">
 
</td>
</tr>

<tr>
<td colspan="7">
 
</td>
</tr>

<tr> <!-- contenu -->
<td colspan="7" valign="top">
<table border="0">
<tr>
<td width="10px"> <!-- gauche -->
 
</td>

<td valign="top" width="650px">
<table border="0">
<tr>
<td colspan="3" class="txtacc">

<form action="admin2.php" method="post">

<table>
<tr>
<td>
Titre de la News :
</td>
<td>
<input type="text" name="titre" />
</td>
</tr>
<tr>
<td>
Texte de la news :
</td>
<td>
<input type="text" name="text" />
</td>
</tr>
<tr>
<td>
image grande :
</td>
<td>
<input type="file" name="imagegrd" />
</td>
</tr>
<tr>
<td>
auteur :
</td>
<td>
<input type="text" name="auteur" />
</td>
</tr>
<tr>
<td>
catégorie :
</td>
<td>
<select name="categorie">
<option value="choix1">photos/vidéos</option>
<option value="choix1">Articles</option>
<option value="choix1">Tutoriels</option>
<option value="choix1">Partenaires</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="valider" />
</td>
</tr>
</table>

</form>

</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- FIN tableau intérieur-->
<table border="0" width="1000px" align="center"> <!-- contact-->
<tr>
<td>
<a class="copi">Création : Simon de Meeûs | Copiright 2013 tout droit réservé</a>
</td>
<td align="right">
<a class="bug"> Signaler un bug</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="25px">
</td>
</tr>
</table>
</body>
</html>




Et de formulaire 2 :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Numters.com</title>
<link rel="stylesheet" type="text/css" href="css.css" />
<link rel="icon" type="image/png" href="image/favicon.png" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="keywords" content="numters informatique article info high-tech tutoriel" />
<meta name="Description" content="Sur ce site vous trouverez des photos et des vidéos insolite, des articles divers en lien avec l'informatique et l'high-tech, divers tutoriaux et bien d'autre choses encore." />
<meta http-equiv="content-language" content="fr" />
<meta name="author" lang="fr" content="Simon de Meeûs" />
</head>
<body class="bg"><!-- fond -->
<table width="100%">
<tr height="100px"> <!-- "contenu" -->
<td>

</td>
</tr>
<tr>
<td>
<table border="0" width="1000px" align="center"> <!-- contact-->
<tr>
<td align="right" width="100%">
 
</td>
</tr>
</table>
<!-- tableau intérieur-->
<table border="0" width="1000px" bgcolor="#ffffff" align="center">

<tr> <!-- ligne inutile haut -->
<td width="10px">
 
</td>
<td colspan="5">
 
</td>
<td width="10px">
 
</td>
</tr>

<tr>
<td>
 
</td>
<td height="50px" valign="top" colspan="5">
<img src="image/logo.png" width="40%" alt="logo"/>
</td>
<td width="10px">
 
</td>
</tr>

<tr>
<td colspan="7">
 
</td>
</tr>

<tr> <!-- contenu -->
<td colspan="7" valign="top">
<table border="0">
<tr>
<td width="10px"> <!-- gauche -->
 
</td>

<td valign="top" width="650px">
<table border="0">
<tr>
<td colspan="3" class="txtacc">

<form action="admin2.php" method="post">

<table>
<tr>
<td>
Titre de la News :
</td>
<td>
<input type="text" name="titre" />
</td>
</tr>
<tr>
<td>
Texte de la news :
</td>
<td>
<input type="text" name="text" />
</td>
</tr>
<tr>
<td>
image grande :
</td>
<td>
<input type="file" name="imagegrd" />
</td>
</tr>
<tr>
<td>
auteur :
</td>
<td>
<input type="text" name="auteur" />
</td>
</tr>
<tr>
<td>
catégorie :
</td>
<td>
<select name="categorie">
<option value="choix1">photos/vidéos</option>
<option value="choix1">Articles</option>
<option value="choix1">Tutoriels</option>
<option value="choix1">Partenaires</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="valider" />
</td>
</tr>
</table>

</form>

</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- FIN tableau intérieur-->
<table border="0" width="1000px" align="center"> <!-- contact-->
<tr>
<td>
<a class="copi">Création : Simon de Meeûs | Copiright 2013 tout droit réservé</a>
</td>
<td align="right">
<a class="bug"> Signaler un bug</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="25px">
</td>
</tr>
</table>
</body>
</html>


A voir également:

1 réponse

tu as mal cherché ou tu as mal lu les tutoriaux:
<form action="admin2.php" method="post" enctype="multipart/form-data">

j'ai testé ton formulaire:
sans ça marche pas,
avec ça marche !
0
Merci beaucoup, je me disais bien que mon erreur était stupide.
0