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); } } }
}