I want to import/upload excel files to sql server via cake php, it will occur Undefined variable: ext and Undefined index: the code are shown as below. Is there any mistake in my code? Thanks in advance!
<?php
App::import('Vendor', 'php-excel-reader/excel_reader2');
class UploadsController extends RealTimeAnalysisAppController
{
public function upload()
{
$destination = realpath('../../app/webroot/uploads/excel/' . '/');
if(isset($_FILES['Upload']['XLS_File']))
$ext = substr($_FILES['Upload']['XLS_File'], strrpos($_FILES['Upload']['XLS_File'], '.') + 1);
$path = $destination.'excel'.$ext;
move_uploaded_file($_FILES['Upload']['tmp_name'], $path);
$data = new Spreadsheet_Excel_Reader($path, true);
$temp = $data->dumptoarray();
if($temp)
{
foreach ($temp as $key=>$val)
{
$val['0'];
}
}
}}