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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <?php
include "fonction.inc.php";
connexion("localhost", "root", "", "ccf");
include "debut.inc.php";
if ((isset($_FILES['envoiFichier']['name'])&&($_FILES['envoiFichier']['error'] == UPLOAD_ERR_OK)))
{
$chemin_destination = 'C:/uploads';
move_uploaded_file($_FILES['envoiFichier']['tmp_name'],
$chemin_destination.$_FILES['envoiFichier']['name']);
}
if (count($_FILES)==0) {
echo"
<form method='post' action='convocationCsv.php' enctype='multipart/form-data'>
<input type='hidden' name='MAX_FILE_SIZE' value='2097152'>
Sélectionner le fichier listeConvocation.csv :</br></br>
<input name = 'envoiFichier' type='file'/></br></br>
<input class='bouton' type='submit' value='Envoyer le fichier'>
</form>
";
}
else {
$row = 1;
if (($handle = fopen("listeConvocation.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
}
$sql = "INSERT INTO ccf_convocation VALUES ('{$data[0]}', '{$data[1]}', '{$data[2]}', '{$data[3]}', '{$data[4]}', '{$data[5]}', '{$data[6]}', '{$data[7]}' )";
$resultat=mysql_query($sql);
}
echo" <p> Liste importer </p>";
fclose($handle);
}
}
include "fin.inc.php";
?> |
Partager