PHP- ça plante :(
charlie.H
-
le père -
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.
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.
A voir également:
- PHP- ça plante :(
- Plante - Guide
- Easy php - Télécharger - Divers Web & Internet
- Mon telephone plante que faire - Guide
- Cette plante encore peu connue fleurit toute l'année - Et elle est magnifique ! - Guide
- Explorateur windows plante - Guide
7 réponses
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 />
<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 />
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Je crois que sa vient de la page pannel.php...
C'est pas grave je vais essayer de refair ele script.
Merci encore!
C'est pas grave je vais essayer de refair ele script.
Merci encore!
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
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