Home:ALL Converter>How to import excel file into mysql database uding php?

How to import excel file into mysql database uding php?

Ask Time:2014-04-10T22:40:14         Author:Yogesh k

Json Formatter

I want to upload userdata into mysql database. For that purpose I want to import excel data into mysql database using php. I have written the code. But I am facing an error. I am providing my code for reference. My code is as follows.

include 'config.php'; 
require_once 'Excel/reader.php';
$allowedExts = array("xls","xlsx");
$temp = explode(".", $_FILES["file"]["name"]);


if (($_FILES["file"]["size"] < 20000)&& (in_array($extension, $allowedExts)))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "<br>";
    }
  else
    {
    $filename=$_FILES["file"]["name"] ;
    $filetype=$_FILES["file"]["type"] ;
    $filesize=$_FILES["file"]["size"] ;
    $filetemp=$_FILES["file"]["tmp_name"];

         //////////////////////////   
            $row=0;
        $handle = fopen($filetemp, "r");

        $data = new Spreadsheet_Excel_Reader();
                $data->read($filetemp);

My code stop executing from this line :

$data = new Spreadsheet_Excel_Reader();

And I am geetting this error on my screen : php28E.tmp is not readable.

Please help me in this question.

Author:Yogesh k,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22991286/how-to-import-excel-file-into-mysql-database-uding-php
rernesto :

You could use phpexcel instead, works perfectly and also supports all kind of spreadsheets formats and it's well documented.\nDownload it at PhpExcel Home.\nThere is a lot of tips and tutorials on google.\n\nThis code works for me:\n\n<?php\n$newPath = __DIR__.'/'.basename($_FILES['filepath']['tmp_name']);\nmove_uploaded_file($_FILES['filepath']['tmp_name'], $newPath);\n$objPHPExcel = PHPExcel_IOFactory::load($newPath);\n............................\n",
2014-04-10T15:08:33
yy