0

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'];

}
}
}}
2
Contributors
1
Reply
20
Views
3 Years
Discussion Span
Last Post by andrevanzuydam
0

Lets just start off with line 11, did you mean to not put an opening bracket on your if statement ?

Edited by andrevanzuydam: spelling mistake

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.