Open_basedir restriction in effect solution in PHPExcel, openbasedir

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.