What file permissions are needed?

Topics: Developer Forum
Nov 2, 2010 at 8:09 PM

What do the file permissions need to be on an uploaded file in order for Excel2007Reader to load() it?

$objReader = PHPExcel_IOFactory::createReader('Excel2007');

$objReader->setReadDataOnly(true);
                    $firephp->info("Ready to load file",$_SERVER['DOCUMENT_ROOT']. "/call_records/".$fileName);
        $objPHPExcel = $objReader->load($_SERVER['DOCUMENT_ROOT']. "/call_records/".$fileName);
                    $firephp->info("Ready to get worksheet");

"Ready to load file" is reported ... but not "Ready to get worksheet".

Some testing led to the idea that permission 000 would word whereas others up to and including 777 would not!  That seemed backwards ... what permissions *do* I need?

 

Thanks!

Daniel

Coordinator
Nov 2, 2010 at 11:19 PM

PHPExcel needs read permission on the file, for the appropriate user or group (whatever user/group your webserver is running as). PHPExcel is no different to any other PHP script in this regard. Wrap your load() call in a try/catch block to trap any error.

try {
    $objReader = PHPExcel_IOFactory::createReader('Excel2007');
    $objReader->setReadDataOnly(true);
    $objPHPExcel = $objReader->load($_SERVER['DOCUMENT_ROOT']. "/call_records/".$fileName);
} catch(Exception $e) {
   die('Error loading file: '.$e->getMessage());
}
Nov 2, 2010 at 11:29 PM

Thanks ...

With that try...catch, the die statement is not occurring.  So I don't think an exception is being thrown.  But $objReader->load is not returning ...

Anything else to check?

Coordinator
Nov 5, 2010 at 12:50 AM

Aside from the obvious... ensure that you're logging/displaying any errors, check for out of memory or timeouts, I can't think of anything.