petit soucis affichage d'image

Eléphanteau du PHP | 12 Messages

30 sept. 2011, 12:18

Bonjour a tous
j'ai travailler sur une page qui permet d'inserer des nouveaux articles sur un site de vente et lorsque j'envoi ma requete tout se passe presque bien la seule chose qui ne va pas est que je n'arrive pas a afficher les images sur la page de destination
Je suis presque certain que ca ne dois pas etre grand chose mais etant encore novice dans le php je ne vois pas
Pourriez vous m'aider svp

voici la page par laquelle j'inserre mes nouveaux produits
<?php
{
if($_POST) // vérifie si le tableau post existe
	{
	if($_POST['envoyer']) // Vérifie si le fichier a été validé
		{
		echo'
			<div class="Body">
		';
		include("menu/menu_Admin.inc.php");
		echo'
			<div STYLE="margin-left:50px;margin-top:50px;width:400px;border:1px solid #d0d0d0;">
		';
		
		if(is_uploaded_file($_FILES['ImgG']['tmp_name']))
			{
			echo "Le fichier ".$_FILES['ImgG']['name']." a bien été téléchargé<br>";
			echo "Il fait ".$_FILES['ImgG']['size']." et est de type ".$_FILES['ImgG']['type']."<br>";
			}
		else
			{
			echo "Le fichier ".$_FILES['ImgG']['name']." n'a pas été téléchargé<br>";
			}
		if(is_uploaded_file($_FILES['ImgP1']['tmp_name']))
			{
			echo "Le fichier ".$_FILES['ImgP1']['name']." a bien été téléchargé<br>";
			echo "Il fait ".$_FILES['ImgP1']['size']." et est de type ".$_FILES['ImgP1']['type']."<br>";
			}
		else
			{
			echo "Le fichier ".$_FILES['ImgP1']['name']." n'a pas été téléchargé<br>";
			}
		if(is_uploaded_file($_FILES['ImgP2']['tmp_name']))
			{
			echo "Le fichier ".$_FILES['ImgP2']['name']." a bien été téléchargé<br>";
			echo "Il fait ".$_FILES['ImgP2']['size']." et est de type ".$_FILES['ImgP2']['type']."<br>";
			}
		else
			{
			echo "Le fichier ".$_FILES['ImgP2']['name']." n'a pas été téléchargé<br>";
			}
		if(is_uploaded_file($_FILES['ImgP3']['tmp_name']))
			{
			echo "Le fichier ".$_FILES['ImgP3']['name']." a bien été téléchargé<br>";
			echo "Il fait ".$_FILES['ImgP3']['size']." et est de type ".$_FILES['ImgP3']['type']."<br>";
			}
		else
			{
			echo "Le fichier ".$_FILES['ImgP3']['name']." n'a pas été téléchargé<br>";
			}

		echo'
			</div></div>
		';
		}
	}

// ============== recherche du prochain ID_Prod ==============

include("tools/db_con.inc.php");
$sql='SELECT ID_Products FROM `tb_products`';
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$result=mysql_query($sql,$db);
$num_rows=mysql_num_rows($result); 
$ID_P=$num_rows+1;

// ===========================================================


if(isset($_POST['Desc_fr']))
	{
	$Desc_fr=$_POST['Desc_fr'];
	}
else
	{
	echo' Veuillez entrer le titre Français, merci!';
	}

if(isset($_POST['Titre_fr']))
	{
	$Titre_fr=$_POST['Titre_fr'];
	}
else
	{
	echo' Veuillez entrer le titre Français, merci!';
	}
if(isset($_POST['Titre_en']))
	{
	$Titre_en=$_POST['Titre_en'];
	}
else
	{
	echo' Veuillez entrer le titre Anglais, merci!';
	}
if(isset($_POST['Categorie']))
	{
	$Categorie=$_POST['Categorie'];
	}
else
	{
	echo' Veuillez sélectionner une catégorie, merci!';
	}
if(isset($_POST['Prix']))
	{
	$Prix=$_POST['Prix'];
	}
else
	{
	echo' Veuillez introduire un prix pour cet article, merci!';
	}
if(isset($Desc_fr)  && isset($Titre_fr) &&  isset($Titre_en))
	{
	include("tools/db_con.inc.php");
	$sql='INSERT INTO `tb_products` (ID_Products,Categorie,Titre_fr,Titre_en,Description_fr,Description_en,Prix,ImgG,ImgP1,ImgP2,ImgP3) Values ("","'.$Categorie.'","'.$Titre_fr.'","'.$Titre_en.'","'.$Desc_fr.'","'.$Desc_en.'","'.$Prix.'","'.$ImgG.'","'.$ImgP1.'","'.$ImgP2.'","'.$ImgP3.'")';
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
	echo " La table Produits a bien été remplie, voici les informations:";
	$sql = "SELECT * FROM `tb_products` WHERE ID_Products=$ID_P" ; 
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
	$result=mysql_query($sql,$db);
	While($row=mysql_fetch_array($result))
		{
		echo'
		<div STYLE="">
			<table cellspacing="0" cellpadding="0" border="0" width="200">
				<tr>
					<td colspan="3">'.$row['Titre_fr'].'</td>
				</tr>
				<tr>
					<td colspan="3">'.$row['Description_fr'].'</td>
				</tr>
				<tr>
					<td colspan="3"><img src="Products/'.$row['ID_Products'].'/'.$row['ImgG'].'" width="120" height="120" border="0"/></td>
				</tr>
				<tr>
					<td><img src="Products/'.$row['ID_Products'].'/'.$row['ImgP1'].'" width="50" height="50" border="0"/></td>
					<td><img src="Products/'.$row['ID_Products'].'/'.$row['ImgP2'].'" width="50" height="50" border="0"/></td>
					<td><img src="Products/'.$row['ID_Products'].'/'.$row['ImgP3'].'" width="50" height="50" border="0"/></td>
				</tr>
				<tr>
					<td colspan="3">Prix : '.$row['Prix'].' €</td>
				</tr>
			</table>
		</div>
		';
		}
	}
else
	{
	echo " La table  Produits n'a pas été remplie";
	}

echo'
<div class="Body">
';
include("menu/menu_Admin.inc.php");
echo'

	<br><br>
	<div class="Add_News">
	<table cellpadding="0" cellspacing="0" border="0" width="515">
		<tr>
			<td>
				<div STYLE="margin-bottom:-5px;font-size:12px;">
					<table cellpadding="0" cellspacing="0" border="0" width="515">
						<td width="6" align="left">
							<img src="pictures/Dep_tl.bmp" width="6" height="34" border="0" />
						</td>
						<td width="188" align="left">
							<img src="pictures/Dep_t.bmp" width="300" height="34" border="0" />
						</td>
						<td width="19" align="left">
							<img src="pictures/Dep_b_txt.bmp" width="19" height="34" border="0" />
						</td>
						<td width="183" STYLE="color:#fff;font-weight:bold;font-size:14px;text-align:center;background-image:url(\'pictures/Dep_txt.bmp\');background-repeat:repeat-x;">
							Ajouter Produits
						</td>
						<td width="7" align="right">
							<img src="pictures/Dep_a_txt2.bmp" width="7" height="34" border="0" />
						</td>
					</table>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<table width="515" border="0" cellpadding="0" cellspacing="0" bgcolor="#BBBBBB" align="center">
					<form method="post" action="" enctype="multipart/form-data">

						<tr>
							<td  width="500" align="center" colspan="2">Titres :</td>
						</tr>
						<tr>
							<td width="150" align="right">Titre fr :&nbsp;</td><td width="350" align="left"><input type="text" name="Titre_fr" size="40"/></td>
						</tr>
						<tr>
							<td width="150" align="right">Titre Ang :&nbsp;</td><td width="350" align="left"><input type="text" name="Titre_en" size="40"/></td>
						</tr>
						<tr>
							<td  width="500" align="center" colspan="2">Catégorie :</td>
						</tr>
						<tr>
							<td width="150" align="right">Choix :&nbsp;</td>
							<td width="350" align="left">
								<select Name="Categorie">
									<option value=""></option>
									<option value="pcs">Ordinateurs complets</option>
									<option value="portables">Portables</option>
									<option value="promos">Promotions</option>
									<option value="pieces">Pièces ordinateur</option>
								</select>
							</td>
						</tr>

						<tr>
							<td width="150" align="right">Fichier description fr :&nbsp;</td><td width="350" align="left"><input type="text" name="Desc_fr" size="40"/></td>
						</tr>
						<tr>
							<td width="150" align="right">Fichier description en :&nbsp;</td><td width="350" align="left"><input type="text" name="Desc_en" size="40"/></td>
						</tr>
						<tr>
							<td  width="500" align="center" colspan="2">Images : (jpg format 4:3)</td>
						</tr>
						<tr>
							<td width="150" align="right">Fichier Grande Image :&nbsp;</td><td width="350" align="left"><input type="file" name="ImgG"/></td>
						</tr>
						<tr>
							<td width="150" align="right">Fichier Petite Image1 :&nbsp;</td><td width="350" align="left"><input type="file" name="ImgP1"/></td>
						</tr>
						<tr>
							<td width="150" align="right">Fichier Petite Image2 :&nbsp;</td><td width="350" align="left"><input type="file" name="ImgP2"/></td>
						</tr>
						<tr>
							<td width="150" align="right">Fichier Petite Image3 :&nbsp;</td><td width="350" align="left"><input type="file" name="ImgP3"/></td>
						</tr>
						<tr>
							<td  width="500" align="center" colspan="2">Prix :</td>
						</tr>
						<tr>
							<td width="150" align="right">Prix du produit :&nbsp;</td><td width="350" align="left"><input type="text" name="Prix" size="10"/>&nbsp;€</td>
						</tr>
						<tr>
							<td colspan="2" width="500"><table width="100%"><tr><td align="right"><input class="input_btn" type="reset" value="Effacer">&nbsp;<input class="input_btn" name="envoyer" type="submit" value="Ajouter"></td></tr></table></td>
						</tr>
					</form>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<div class="rech_client_bot">
					<img src="pictures/Form_bot.bmp" Width="515" Height="9"/>
				</div>
			</td>
		</tr>
	</table>
	</div>
</div>
';
}

?>
Et voici celle ou mes produites devrais s'afficher avec les images (qui elles ne s'affichent pas )
<?php
include("tools/db_con.inc.php");
$sql = "SELECT * FROM `tb_products` WHERE Categorie='pcs'" ; 
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
	$result=mysql_query($sql,$db);
	
echo'
<div class="BodyProd">
<br/>
<div STYLE="width:300px;background:#ff0;font-size:18px;font-weight:bold;margin-left:20%;margin-right:20%;text-align:center;">
PC\'s complets avec options
</div>
<br/><br/>
';
		While($row=mysql_fetch_array($result))
			{
			echo'
			<div STYLE="border:1px solid #bbb;width:670px;padding:5px;">
				<table cellspacing="0" cellpadding="0" border="0" width="660">
					<tr>
						<td colspan="5" align="center"><div STYLE="font-size:14px;color:#00f;font-weight:bold;">'.$row['Titre_fr'].'&nbsp;<font color="#acacac" size="10px">[id:'.$row['ID_Products'].']</font></div></td>
					</tr>
					<tr>
						<td colspan="3">
							<a href="#" class="info2">
								<img src="Products/'.$row['ID_Products'].'/'.$row['ImgG'].'" width="160" height="120" border="0"/>
									<span>
										<div STYLE="border:3px solid #bbbbff;width:400px;height:300px;">
											<table cellspacing="0" cellpadding="0" border="0">
												<tr>
													<td>
														<img src="Products/'.$row['ID_Products'].'/'.$row['ImgG'].'" width="400" height="300" border="0"/>
													</td>
												</tr>
											</table>
										</div>
									</span>
							</a>
						</td>
						<td colspan="2" width="500">
						<div STYLE="width:500px;padding-left:5px;padding-right:5px;font-size:14px;">';
						echo $row['Description_fr'];
						echo'</div></td>
					</tr>
					<tr>
						<td colspan="5"></td>
					</tr>
					<tr>
						<td width="53" align="center">
							<a href="#" class="info2">
								<img src="Products/'.$row['ID_Products'].'/'.$row['ImgP1'].'" width="50" height="30" border="0"/>
									<span>
										<div STYLE="border:3px solid #bbbbff;width:400px;height:300px;">
											<table cellspacing="0" cellpadding="0" border="0">
												<tr>
													<td>
														<img src="Products/'.$row['ID_Products'].'/'.$row['ImgP1'].'" width="400" height="300" border="0"/>
													</td>
												</tr>
											</table>
										</div>
									</span>
							</a>
						</td>
						<td width="53" align="center">
							<a href="#" class="info2">
								<img src="Products/'.$row['ID_Products'].'/'.$row['ImgP2'].'" width="50" height="30" border="0"/>
									<span>
										<div STYLE="border:3px solid #bbbbff;width:400px;height:300px;">
											<table cellspacing="0" cellpadding="0" border="0">
												<tr>
													<td>
														<img src="Products/'.$row['ID_Products'].'/'.$row['ImgP2'].'" width="400" height="300" border="0"/>
													</td>
												</tr>
											</table>
										</div>
									</span>
							</a>
						</td>
						<td width="53" align="center">
							<a href="#" class="info2">
								<img src="Products/'.$row['ID_Products'].'/'.$row['ImgP3'].'" width="50" height="30" border="0"/>
								<span>
										<div STYLE="border:3px solid #bbbbff;width:400px;height:300px;">
											<table cellspacing="0" cellpadding="0" border="0">
												<tr>
													<td>
														<img src="Products/'.$row['ID_Products'].'/'.$row['ImgP3'].'" width="400" height="300" border="0"/>
													</td>
												</tr>
											</table>
										</div>
									</span>
							</a>
						</td>
						<td width="400">
						</td>
						<td align="right" width="100" STYLE="background:#ff0;">
							Prix : <b>'.$row['Prix'].' €</b>
						</td>
					</tr>
				</table>
			</div>
			<br>
			';
			}

echo'
</div>
';

?>

Je vous remercie d'avance pour vos conseils

ViPHP
xTG
ViPHP | 7331 Messages

30 sept. 2011, 13:06

Regardes la source HTML générée et plus particulièrement l'adresse des images indiquée.
Tu auras déjà une piste de réponse.

ViPHP
ViPHP | 2577 Messages

30 sept. 2011, 15:20

Je n'ai pas trouver de fonction move_uploaded_file() dans ton code (http://php.net/manual/fr/function.move- ... d-file.php).

Eléphanteau du PHP | 12 Messages

30 sept. 2011, 18:14

Je n'ai pas trouver de fonction move_uploaded_file() dans ton code (http://php.net/manual/fr/function.move- ... d-file.php).
tu a raison je ne le vois pas non plus
pourrais tu me dire ou je dois le mettre stp
Merci

Eléphanteau du PHP | 12 Messages

30 sept. 2011, 18:22

J'avais ceci en mov_uploaded
mais je pense qu'il y a une erreur dedans car quand je le met rien ne se passe non plus
if(move_uploaded_file($_FILES['ImgG']['tmp_name'],"./Products/".$ID_P."/".$_FILES['ImgG']['name']))
	{
	$ImgG=$_FILES['ImgG']['name'];
	$okimgG="1";
	}
Mes images sont stockées dans le fichier ./Products/sous dossier 1 ou 2
ce n'est pas moi qui ai créé ce code

Voici le message que je recois lorque j'envois

Code : Tout sélectionner

Le fichier Chrysanthemum.jpg a bien été téléchargé Il fait 879394 et est de type image/jpeg Le fichier n'a pas été téléchargé Le fichier n'a pas été téléchargé Le fichier n'a pas été téléchargé
Donc le fichier demander est bien créé mais les images ne s'affichent pas c'est la seule chose qui me pose probleme