-1

I need to upload excel file in to mysql db, i can upload csv, but excel file not uploading properly

here is my code

<?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.";
}
}
?>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Kannan Chakkara
  • 181
  • 4
  • 16
  • possible [duplicate](http://stackoverflow.com/questions/563670/reading-an-excel-file-in-php) – DevDonkey Jul 06 '15 at 08:27
  • Check my answer for this question: http://stackoverflow.com/questions/31018419/how-can-i-import-excel-file-in-mysql/31023921#31023921 – alex.pulver Jul 06 '15 at 09:26

1 Answers1

-1

You need to use PHPExcel library for access to excel file.

Daniel
  • 350
  • 4
  • 12