PHPExcel_Writer_Excel5->setTempDir() not passed to all classes involved in writing to a file.

Topics: Developer Forum, Project Management Forum, User Forum
Aug 9, 2008 at 7:10 AM
Hi all,

I am having troubles when I am trying to run my code using this library on my production server (a shared server where I have minimal to no control). The server has a open_basedir configuration that does not allow access to the system's /tmp directory.

I found the PHPExcel_Writer_Excel5->setTempDir() method and assumed that this would fix the issue however I still get the following warnings and error;

Warning: tmpfile() [function.tmpfile]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s) in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Worksheet.php on line 477

Warning: tmpfile() [function.tmpfile]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s) in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Worksheet.php on line 477

Warning: tmpfile() [function.tmpfile]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s) in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Worksheet.php on line 477

Warning: tmpfile() [function.tmpfile]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s) in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Worksheet.php on line 477

Warning: tempnam() [function.tempnam]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s) in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Shared/OLE/OLE_File.php on line 87

Fatal error: Uncaught exception 'Exception' with message 'Can't create temporary file' in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Shared/OLE/OLE_File.php:90 Stack trace: #0 /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Workbook.php(580): PHPExcel_Shared_OLE_PPS_File->init() #1 /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Workbook.php(548): PHPExcel_Writer_Excel5_Workbook->_storeOLEFile() #2 /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5/Workbook.php(225): PHPExcel_Writer_Excel5_Workbook->_storeWorkbook() #3 /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Writer/Excel5.php(322): PHPExcel_Writer_Excel5_Workbook->close() #4 /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/admin.assess.php(1245): PHPExcel_Writer_Excel5->save('compo in /home/lo/log/logss.com.au/public/www/site/administrator/components/com_assess/lib/PHPExcel/Shared/OLE/OLE_File.php on line 90
Is there any suggestions on how I can get around this.


Coordinator
Aug 12, 2008 at 7:29 AM
Has been resolved in http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=7276
Aug 12, 2008 at 8:47 AM
Thank you maartenba. I sorry to be ignorant but how do I get this fix? Cheers
Coordinator
Aug 12, 2008 at 9:40 AM
You can use the top-most download link at http://www.codeplex.com/PHPExcel/SourceControl/ListDownloadableCommits.aspx.
Aug 16, 2008 at 3:50 AM
Edited Aug 16, 2008 at 3:51 AM
Hi maartenba
I'm not sure if this is related to this previous issue or not. When I got the fix for the last issue I did a quick test on the production server, got no error messages but didn't look at the output. Now I have finished development, adding graphs by using the jpGraph library and then inserting the resultant images (.png) as worksheet_drawings. It all works beautifully on my Windows development box. Now onto the production server (Linux) for some heavy duty testing. No errors, but the only thing in the outputted .xls file is the graphs, no data. The each indivual worksheet is there, named correctly and with it's relevent graphs but no data.
Developer
Aug 26, 2008 at 2:15 PM
Anyone knows what part of the PHP configuration that is causing this?

I am trying to alter my php.ini to recreate your problem, but the "problem" is that I never seem to get your open_basedir warning message for the tmpfile() function, although I do get warning message for the tempnam() when I set the open_basedir to some value outside the systems tmp directory.

I have verified that temporary files are being created in the tmp directory by the tmpfile() function even with open_basedir restriction, so it seems that tmpfile() is unaffected by open_basedir setting which I don't understand. I have tried on both Linux and Windows and both show the same behaviour. tmpname() stops working when open_basedir is outside the temporary directory, but tempfile() continues to work.

Maybe you can send us a link to your phpinfo and something will be revealed?
Aug 26, 2008 at 3:51 PM
koyama: do you use error_reporting with E_ALL and E_STRICT, and with display_errors = On ?
maybe using: "user_dir = ..." helps you to find the error.
and "upload_tmp_dir =" must not setted to /tmp
but the easy way is, if GeoffreyB just give us he's php.ini :)
Aug 26, 2008 at 10:12 PM
Hi koyama & b166er, The issue is now not the open_basedir warnings since I am using the code as mentioned in Maartena's last post, the problem is now that I get correctly formated spreadsheets with correctly created graphs (inserted as images, created with jpGraph) but no data. See my later discussion No data in cells. The link to my phpinfo is http://logss.com.au/phpinfo.php.
I really appreciate everyone's help here. I need to be able to deliver this to my client really soon. Thanks
Developer
Aug 26, 2008 at 11:14 PM
b166er: yes, I had indeed set all errors to display.
GeoffreyB: thanks for the link, although I don't really see anything suspicious. I understand that warning messages are gone, but it sounds like the new problem is linked to this one. Ok, will instead look at the other post.