Open_basedirrestrictionineffect solution in PHPExcel: openbasedir. Open_basedirrestrictionineffect solution in PHPExcel. openbasedir used PHPExcel to export execl and found that there was no problem locally. However, when the website was uploaded to the rented server, the open_basedir restriction in effect solution in PHPExcel, openbasedir
When export execl using PHPExcel, it is found that there is no problem locally, but an error is reported when the website is uploaded to the rented server, as follows:
Warning: realpath () [function. realpath]: open_basedir restriction in effect. file (/tmp) is not within the allowed path (s): (/data/home:/usr/home:/data/home/tmp:/usr/home/tmp: /var/www/disablesite) in/data/home/[server name]/htdocs/[project address]/Classes/PHPExcel/Shared/File. php on line 136 finds the corresponding File. the first line of php is the last line of the sys_get_temp_dir method. check the online method and replace the method directly.
The code is as follows:
public static function sys_get_temp_dir()
{
if (ini_get('upload_tmp_dir')!==false) { if($temp = ini_get('upload_tmp_dir')) { if (file_exists($temp)) { return realpath($temp); } } } if ( !function_exists('sys_get_temp_dir')) { if ($temp = getenv('TMP')) { if (file_exists($temp)) { return realpath($temp); } if (($temp!='') && file_exists($temp)) { return realpath($temp); } } if ($temp = getenv('TEMP')) { if (file_exists($temp)) { return realpath($temp); } } }
}
Revoke restriction in effect solution: openbasedir used PHPExcel to export execl and found that there was no problem locally, but when the website was uploaded to the rented server...