Phpexcel Can Not Read Upload File

I want to upload a Excel spreadsheet from the client and then on the server read the spreadsheet and write data to MySQL. I have no need to retain the spreadsheet on the server. I just need to make DB updates. I have phpexcel installed and am able to build and download spreadsheets to the client with no issue.

I am able to display a form, collect the file name, and submit the form. When I try to create a reader with:

$reader = PHPExcel_IOFactory::createReaderForFile($fileName);

I get:

include(PHPExcel_IOFactory.php): failed to open stream: No such file or directory

Can anyone offer suggestions to help me figure out what I am doing wrong? I want to use phpexcel but am not married to this particular approach so I am very open to criticism or suggestions.


class TransactionsUploadController extends Controller


    public function actionCreate()


        $model=new TransactionsUpload;





            $fileName = $model->uploadedFile->getTempName();

            echo $fileName;

            $reader = PHPExcel_IOFactory::createReaderForFile($fileName);

            $objPhpExcel = $reader->load($fileName);

            foreach($objPhpExcel->getWorksheetIterator() as $worksheet){

                echo $worksheet->getTitle();

                // will do work here.......................



        $this->render('upload', array('model'=>$model));



class TransactionsUpload extends CFormModel


    public $uploadedFile;

    public function rules()


        return array(

        array('uploadedFile', 'file', 'types'=>'xlsx'),




$form = $this->beginWidget(



        'id' => 'upload-form',

        'enableAjaxValidation' => false,

        'htmlOptions' => array('enctype' => 'multipart/form-data'),



// ...

echo $form->labelEx($model, 'uploadedFile');

echo $form->fileField($model, 'uploadedFile');

echo $form->error($model, 'uploadedFile');

echo CHtml::submitButton('Submit', array('name'=>'submit'));

// ...


Seems to be a class autoloading issue. Here’s a code example that might help you.

phtamas, thx for the reply.

I am probably misreading the error. I thought phpexcel was not finding the file I referenced. I now see php is not finding PHPExcel_IOFactory.php?

I am using PHPExcel to build and download A spreadsheet and it loads PHPExcel_IOFactory:createWriter and has no issue so I assumed I had the phpexcel vs yii autoloader issue correctly configured.

I have read the entry you referenced and a couple of others. Seems to be several approaches to dealing with the issue and I am not sure what makes the best sense.

I open to input.


Nathan Reed