importation fichier CSV avec php et mysql
bonjour ,
j'ai un souci d'upload du fichier CSV
Code:
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
|
<?php
$connect = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("csv",$connect);
if(isset($_POST['submit']))
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file,"r");
while(($filop = fgetcsv($handle,250,",")) !==false)
{
$firstname = $filop[0];
$lastname = $filop[1];
$email = $filop[2];
$sql = mysql_query("INSERT INTO base_info(name,username,email) VALUE('$firstname','$lastname','$email')");
if(sql)
{
echo $filop[1];
}
}
}
?>
<form method="POST" action="index.php" enctype="multipart/form-data">
<input type="file" name="text">
<input type="submit" name="submit" value="envoyer">
</form> |
Merci d'avance .