PHP- ça plante :(

charlie.H -  
 le père -
Bonjour,

Bon, voila, je suis un gros débutant en php, et je n'arrive pas a transmettre le contenu d'un fichier vers un textarea... Aidez moi svp.
Voici les codes:

--------------------------modification.php---------------------------

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>

<body>
<form method="post" action="modification.php">
<TEXTAREA name="modif" rows="15" COLS="60">
<?php
$monfichier = $_POST['monfichier'];
$fp = fopen ("$monfichier", "r");
$contenudufichier = fgets ($fp, 1024);
fseek ($fp, 0);
fclose ($fp);
echo ".$contenudufichier.";
?>
</TEXTAREA>
<br/><input type="submit" name="boutton" value="Enregistrer">
</form>
</body>
</html>



---------------pannel.php----------------------

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
<style type="text/css">
<!--
.imput {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 14px;
font-weight: normal;
font-variant: small-caps;
color: #069;
background-color: #FFF;
height: 20px;
width: 60%;
border: thin dotted #090;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="modification.php">

<?php
function mkmap($dir){
$folder = opendir ($dir);

while ($file = readdir ($folder)) {
if ($file != "." && $file != "..") {
$pathfile = $dir.'/'.$file;
echo "<input type=\"radio\" name=\"monfichier\" id=\"monfichier\" value=\"monfichier\" />$pathfile <br /> ";
if(filetype($pathfile) == 'dir'){
mkmap($pathfile);
}
}
}
closedir ($folder);
}
?>

<?php mkmap('..'); ?>
<br /><br />
<center><input type="submit" name="ok" id="ok" value="Modifier le fichier" /></center>
</form>
</body>
</html>



Dans mon textarea sa me mets: "<br />
<b>Warning</b>: fopen(monfichier) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>C:\wamp\www\test\modification.php</b> on line <b>13</b><br />
<br />
<b>Warning</b>: fgets(): supplied argument is not a valid stream resource in <b>C:\wamp\www\test\modification.php</b> on line <b>14</b><br />
<br />
<b>Warning</b>: fseek(): supplied argument is not a valid stream resource in <b>C:\wamp\www\test\modification.php</b> on line <b>15</b><br />
<br />
<b>Warning</b>: fclose(): supplied argument is not a valid stream resource in <b>C:\wamp\www\test\modification.php</b> on line <b>16</b><br />
..
"

Merci.
Configuration: Windows Vista
Firefox 3.0.11

7 réponses

  1. Dalida Messages postés 7114 Date d'inscription   Statut Contributeur Dernière intervention   923
     
    salut,
    <?php
    $monfichier = $_POST['monfichier'];
    echo  file_get_contents ($monfichier);
    ?> 
    1
  2. charlie.H
     
    Ok, merci je vais essayer ta solution ;)
    0
  3. charlie.H
     
    Sa me met encore un message d'erreur:

    <br />
    <b>Warning</b>: file_get_contents(monfichier) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in <b>C:\wamp\www\test\modification.php</b> on line <b>13</b><br />
    0
  4. Dalida Messages postés 7114 Date d'inscription   Statut Contributeur Dernière intervention   923
     
    No such file or directory
    je peux difficilement te dire mieux, le fichier n'existe pas.
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. charlie.H
     
    Je crois que sa vient de la page pannel.php...

    C'est pas grave je vais essayer de refair ele script.

    Merci encore!
    0
  7. Dalida Messages postés 7114 Date d'inscription   Statut Contributeur Dernière intervention   923
     
    le fichier n'existe pas
    c'est pas plus compliqué que ça !
    -:o)
    0
  8. le père
     
    Bonjour

    Tu fais la liste des fichiers du répertoire parent : mkmap('..');
    Mais ensuite tu le cherches dans le répertoire courant :
    $monfichier = $_POST['monfichier'];
    $fp = fopen ("$monfichier", "r");

    Normal qu'il n'y soit pas, ce n'est plus le même répertoire
    Essaye
    $monfichier = '../'.$_POST['monfichier'];
    $fp = fopen ("$monfichier", "r");

    Ça devrait mieux marcher
    0