我需要将excel文件上传到mysql db,我可以上传csv,但excel文件无法正常上传
这是我的代码
<?php
include ("connection.php");
if(isset($_POST["submit"]))
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file, "r");
$c = 0;
while (($emapData = fgetcsv($handle, 10000, ",")) !== FALSE)
{
$c++;
if($c>1){
$sql = "INSERT into `table`(`name`,`email`) values('$emapData[0]','$emapData[1]')";
mysql_query($sql);
}
}
if($sql){
echo "You database has imported successfully. You have inserted ". $c ." recoreds";
}else{
echo "Sorry! There is some problem.";
}
}
?>
答案 0 :(得分:-1)
您需要使用PHPExcel库来访问excel文件。