Open_basedir problem

Topics: Developer Forum, User Forum
Mar 4, 2009 at 8:10 AM
09:50:54 Create new PHPExcel object 09:50:54 Set properties 09:50:54 Add some data 09:50:54 Rename sheet 09:50:54 Write to Excel2007 format
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/PHPExcel/Writer/Excel2007.php) is not within the allowed path(s): (/var/www/vhosts/domein.be/httpdocs:/tmp) in /var/www/vhosts/domein.be/httpdocs/schooladministratie/PHPExcel/Classes/PHPExcel/IOFactory.php on line 170

Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Tests/01simple.xlsx.' in /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php:401 Stack trace: #0 /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Tests/01simple.php(75): PHPExcel_Writer_Excel2007->save('/var/www/vhosts...') #1 {main} thrown in /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php on line 401

Can anyone fix this please??

Thankx in advance!
Developer
Mar 4, 2009 at 8:25 AM
From the error message it looks like there is a problem with your include path. Make sure that your include path does not include the root '/'.

Alternatively, disable the open_basedir in your php.ini, but it is better to fix the include path.

Mar 4, 2009 at 9:35 AM
Where can I do that?

In 01simple.php:

/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');

Do I have to change these line?

Thankx for the fast reply!


Developer
Mar 4, 2009 at 9:44 AM
What is your current include path?

var_dump(get_include_path());

Mar 5, 2009 at 7:27 AM
This is what I get: string(14) ".::../Classes/"

When I use this code:

/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
var_dump(get_include_path());
Developer
Mar 5, 2009 at 11:18 PM
Edited Mar 5, 2009 at 11:34 PM
Yeah, your include path looks a bit weird; there are two adjacent path separators. Can you try this instead:

set_include_path('.' . PATH_SEPARATOR . '../Classes');

Edit: Removed trailing slash after Classes.

Mar 9, 2009 at 2:36 PM
Edited Mar 9, 2009 at 2:37 PM
My include path is now: string(12) ".:../Classes"
That's 1 ":" less.

But now I get the same:

15:35:14 Create new PHPExcel object 15:35:14 Set properties 15:35:14 Add some data 15:35:14 Rename sheet 15:35:14 Write to Excel2007 format
Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Tests/01simple.xlsx.' in /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php:401 Stack trace: #0 /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Tests/01simple.php(76): PHPExcel_Writer_Excel2007->save('/var/www/vhosts...') #1 {main} thrown in /var/www/vhosts/domein.be/httpdocs/administratie/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php on line 401

:-s
Thx in advance!
Developer
Mar 9, 2009 at 3:10 PM
Likely to be a permission problem:
http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=47209

Mar 10, 2009 at 8:48 AM
That's it!!

Thank you very much! The folder wasn't set to 777.