Probleme en execution php

Résolu
Bonjour,
test.html
<html>
<head>
<title>test</title>
</head>
<body>
<form name="form1"  method="post" action="test.php">
  <input type="file" name="file"  />
  <input  type="submit" value="Submit" />
</form>

test.php
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?php
echo $_FILES["file"]["name"];
?>
</body>
</html>

quand je clique sur envoyer j ai l'erruer suivante
Notice: Undefined index: file in C:\wamp\www\imagetest\test.php on line 7

7 réponses

  1. Contributeur
    html>
    <head>
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    echo ' $_FILES["file"]["name"]';
    ?>
    </body>
    </html>
    


    1. avec
      echo ' $_FILES["file"]["name"]';
      
      j'ai a l'affichage $_FILES["file"]["name"] mais je veux afficher le nom de fichier
      1. Bonjour,

        Vas voir qq tutos de base sur le php car

        si tu fais Avec

        echo ' $_FILES["file"]["name"]';


        la ' empèche l'interprétation de la variable php

        exemple:
        si $a =20;
        echo '$a'; t'affiche $a
        echo $a; t'affiche 20
        echo "$a"; t'affiche aussi 20

        alors soit tu mets:

        Avec
        
        echo " $_FILES['file']['name']";
        
        ou
        
        
        
        echo  $_FILES['file']['name'];
        
        
        
        1. aier moi le probleme contenu
          Notice: Undefined index: file in C:\wamp\www\imagetest\test.php on line 7
          Le nom de l'élément input n'est pas accepte
          1. il faut faire le test isset

            
            if(isset($_FILES['file']['name'])) {
            echo  $_FILES['file']['name'];
            
            }