J'ai Crée une Form...Pour pouvoir rajouter des nouveaux Produits en html...
<form action="secret2.php" enctype="multipart/form-data" method="post">
Product Name: <input type="text" name="Prodname"><br>
Product Number: <input type="text" name="Prodnum"><br>
Product Description: <input type="text" name="Desc"><br>
<p>
Picture: <input type="file" name="fichier" size="30">
</p>
<input type="submit" name="Create" value="Create" /></strong>
</form>
Et Voici Secret2.php
<?php
// Session start
session_start();
// Checks password and username
if($Prodname != null AND $desc != null) {
echo "Fill in Everything bbefore submitting!";
} else {
if( isset($_POST['Create']) ) // si formulaire soumis
{
$content_dir = 'Photos/'; // dossier où sera déplacé le fichier
$tmp_file = $_FILES['fichier']['tmp_name'];
if( !is_uploaded_file($tmp_file) )
{
exit("Le fichier est introuvable");
}
// on vérifie maintenant l'extension
$type_file = $_FILES['fichier']['type'];
if( !strstr($type_file, 'jpg') && !strstr($type_file, 'jpeg') && !strstr($type_file, 'bmp') && !strstr($type_file, 'gif') )
{
exit("Le fichier n'est pas une image");
}
// on copie le fichier dans le dossier de destination
$name_file = $_FILES['fichier']['name'];
if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
{
exit("Impossible de copier le fichier dans $content_dir");
}
echo "File Uploaded Properly!";
$myFile1 = "config/linkmnu.php";
$fh1 = fopen($myFile1, 'w') or die("can't open file");
$stringData = "links[$Prodnum]='http://www.vintage-grace.com/products/$Prodname.html';\n";
fwrite($fh1, $stringData);
fclose($fh1);
$myFile2 = "config/admnu.php";
$fh2 = fopen($myFile2, 'w') or die("can't open file");
$stringData2 = " ad[$Prodnum]='/Photos/$name_file';\n";
fwrite($fh2, $stringData2);
fclose($fh2);
echo "Le fichier a bien été édité";
}
exit;
echo "file not upladed";
}
?> C'est surtout a la fin que je veux m'interresser!
$myFile1 = "config/linkmnu.php";
$fh1 = fopen($myFile1, 'w') or die("can't open file");
$stringData = "links[$Prodnum]='http://www.vintage-grace.com/products/$Prodname.html';\n";
fwrite($fh1, $stringData);
fclose($fh1);
$myFile2 = "config/admnu.php";
$fh2 = fopen($myFile2, 'w') or die("can't open file");
$stringData2 = " ad[$Prodnum]='/Photos/$name_file';\n";
fwrite($fh2, $stringData2);
fclose($fh2);
echo "Le fichier a bien été édité";
Quand je l'utilise, Le Fichier est completement remplacé par cette ligne, alors Que moi je voudrai simplement en rajouter une nouvelle ligne...Est-ce possible?? Mercii!!
~Tom