Bonjour,

J'ai un menu contenant des articles lorsque je souhaite ajouter un article il faut que j'ajoute un bloc HTML dans mon fichier.
Il ajoute bien ce bloc dans mon fichier mais pas au bon endroit...Au lieu de l'ajouter avant, il l'ajoute après.........

Voici mon code

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
17
18
19
20
21
22
23
24
25
26
27
28
29
 
<?php
	$titre_doc=$_POST['titre_doc'];
	$chemin_fichier=$_FILES['chemin_fichier']['tmp_name'];
	copy($chemin_fichier,'C:\wamp\www\contenu\articles\test_ajour_rub\\'.str_replace(" ","_",$_FILES['chemin_fichier']['name']));
$fd = fopen('C:\wamp\www\contenu\articles\test_ajout_rub\index_test_ajout_art.php',"r+");
 
 
    if (!$fd) die("Impossible d'ouvrir le fichier");
    $i=1;
    while (!feof($fd)) {
        $ligne = fgets($fd, 1024);
        if (!feof($fd)){
          if (strpos($ligne,'<td id="ajout_doc">')!==false){
                    $ligne .='
			<td><img src="<?php echo $_DOSSIER_FORME; ?>images/fleche_link_orange.gif" ></td>
			<td>'.$titre_doc.' :</td>
			<td><a href="contenu/articles/test_ajout_rub/'.str_replace(" ","_",$_FILES['chemin_fichier']['name']).'" target="blank"><img src="<?php echo $_DOSSIER_FORME; ?>images/icone_pdf_large.jpg" alt="Visualiser le fichier..."/></a></td>
		</tr>'."\n";
          }
          $i++;
    $new_content .= $ligne;
        }
    }
  fclose($fd);
 
 $fd = fopen('C:\wamp\www\contenu\articles\test_ajout_rub\index_test_ajout_art.php',"w+");
 $doc_write = fwrite($fd,$new_content);
 fclose($fd); ?>
J'ai aussi un soucis avec la copie de mon fichier

Warning: copy(C:\wamp\www\contenu\articles\test_ajour_rub\Nouveau_Texte_seulement.txt) [function.copy]: failed to open stream: No such file or directory in C:\wamp\www\contenu\articles\test_ajout_rub\ajout_doc.php on line 4

Merci