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
session_start();
$userfile = $_POST['userfile'];
echo $userfile;
// UPLOAD DU FICHIER CSV, vérification et insertion en BASE
if($_FILES[$userfile]["type"] != "application/vnd.ms-excel"){
die("Ce n'est pas un fichier de type .csv");
}
elseif(is_uploaded_file($_FILES[$userfile]['tmp_name']))
{
/*
$handle = fopen($_FILES['userfile']['tmp_name'], "r");
$data = fgetcsv($handle, 1000, ";"); //Remove if CSV file does not have column headings
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$att0 = mysqli_real_escape_string($conn,$data[0]);
$att1 = mysqli_real_escape_string($conn,$data[1]);
$att2 = mysqli_real_escape_string($conn,$data[2]);
$att3 = mysqli_real_escape_string($conn,$data[3]);
}
*/
$handle = fopen($_FILES['userfile']['tmp_name'], "r");
$data = fgetcsv($handle, 1000, ";"); //Remove if CSV file does not have column headings
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
$num = count($data);
echo $num;
}
}
mysqli_close($conn);
//header("Location:/sms/pages/acceuil.html");
?>
<script language="JavaScript">
alert("importation Reussie");
window.location.replace("../pages/acceuil.php");
</script>
<?php
?> |
Partager