open_basedir restriction in effect error

Topics: Developer Forum, Project Management Forum, User Forum
Jul 28, 2008 at 9:07 PM
Hi
My hosting provider has their server lock down very tightly security wise and when run my script to produce an Excel spreadsheet from MySql data I get the following warnings.


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


Can anyone suggest a work around or a hack to the Writer class.
Cheers and Thanks in advance
Geoffrey
Coordinator
Aug 11, 2008 at 1:19 PM
You can use the PHPExcel_Writer_Excel5 method "setTempDir" to set a temp files path within the root of your website.
Aug 11, 2008 at 8:29 PM
Thanks Maartenba,
These errors occurs with the PHPExcel_Writer_Excel5->setTempDir() set to within the webroot. See my later post http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=33214
Coordinator
Aug 12, 2008 at 6:29 AM
Has been resolved in http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=7276
Mar 21, 2011 at 10:11 PM

/**
 * Set temporary storage directory
 *
 * @deprecated
 * @param	string	$pValue		Temporary storage directory
 * @throws	Exception	Exception when directory does not exist
 * @return PHPExcel_Writer_Excel5
 */
public function setTempDir($pValue = '') {
	return $this;
}

and where is the assignment of temporary directory?! )))

PHPExcel 1.7.6

Apr 14, 2012 at 4:39 PM

Have a look at http://phpexcel.codeplex.com/workitem/17840, that solved a similar problem for me