Bonsoir,
Je cherche a afficher une image en php tel que quand je Click sur un bouton parcourir l'image s'affiche ,j'ai essayer plusieurs codes mais sa ne marche pas ,voici mon code:
Page formulaire_image.php
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
<html>
<body>
<form action="image.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Page image.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $_FILES["file"]["tmp_name"]."<br>";
  $var=$_FILES["file"]["name"];//$var récupère le nom de l'image
  echo " $var <br>";
  print  "<img src=<?php echo '$var' ; ?> >  ";//Pour l'affichage de l'image
  }
?>
Merci d'avance pour aide