Solution to open_basedir restriction in effect in PHPExcel

WBOY
Release: 2016-07-29 08:56:39
Original
1385 people have browsed it

When using PHPExcel to export execl, I found that there was no problem locally, but when I transferred the website to the rented server, an error was reported. The details are 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/【服务器名称】/htdocs/【项目地址】/Classes/PHPExcel/Shared/File.php on line 136 找到对应的File.php的136行,只是sys_get_temp_dir方法的最后一行,查阅网上的方法直接把该方法给替换掉就好了。 
Copy after login

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); } } }
}
Copy after login

The above introduces the solution to the open_basedir restriction in effect in PHPExcel, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!