用PHPExcel做导出execl的时候发现在本地没有问题,但是把网站传到租用的服务器的时候就报错,具体如下:

  1. 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
  2.  
  3. 找到对应的File.php136行,只是sys_get_temp_dir方法的最后一行,查阅网上的方法直接把该方法给替换掉就好了。

代码如下:

  1. public static function sys_get_temp_dir()
    {
    if (ini_get('upload_tmp_dir')!==false)
  2. {
  3. if($temp = ini_get('upload_tmp_dir'))
  4. {
  5. if (file_exists($temp))
  6. {
  7. return realpath($temp);
  8. }
  9. }
  10. }
  11. if ( !function_exists('sys_get_temp_dir'))
  12. {
  13. if ($temp = getenv('TMP'))
  14. {
  15. if (file_exists($temp))
  16. {
  17. return realpath($temp);
  18. }
  19. if (($temp!='') && file_exists($temp))
  20. {
  21. return realpath($temp);
  22. }
  23. }
  24. if ($temp = getenv('TEMP'))
  25. {
  26. if (file_exists($temp))
  27. {
  28. return realpath($temp);
  29. }
  30. }
  31. }
    }

PHPExcel中open_basedir restriction in effect的解决方法的更多相关文章

  1. LNMP - Warning: require(): open_basedir restriction in effect错误解决方法

    LNMP 1.4或更高版本如果不想用防跨目录或者修改.user.ini的防跨目录的目录还需要将 /usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param ...

  2. open_basedir restriction in effect,解决php引入文件权限问题

    一.前言 今天在Ubuntu安装了lnmp环境,运行项目的时候出现了,引入500的错误 二.查看错误 再项目文件入口添加,代码显示错误内容,查看到一下错误 ini_set('display_error ...

  3. open_basedir restriction in effect,解决php引入文件权限问题 lnmp

    1.配置了虚拟域名 vim /usr/local/nginx/conf/vhost/siemens.conf server { listen 80; #listen [::]:80 default_s ...

  4. 使用宝塔配置laravel站点时,遇到open_basedir restriction in effect. 原因与解决方法

    今天一位朋友在linux服务器部署thinkphp5的时候PHP报了这个错误,如下: Warning: require(): open_basedir restriction in effect. F ...

  5. require(): open_basedir restriction in effect. 解决方法

    在linux服务器部署thinkphp5的时候PHP报了这个错误, 如下: Warning: require(): open_basedir restriction in effect. File(/ ...

  6. open_basedir restriction in effect,解决php引入文件权限问题 解决方法

    如下: 出现问题的原因: 查看问题描述以及资料,发现是php open_basedir 配置的问题,PHP不能引入其授权目录上级及其以上的文件: 一般情况下是不会出现这种问题的,之所以出现这个问题绝大 ...

  7. php错误提示 open_basedir restriction in effect 解决

    <VirtualHost *:80> DocumentRoot "D:/www/4w_raaaa_com_2017" ServerName www.raaaa.com: ...

  8. 解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办

    解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办 问题是出现在了PHP.INI上面了 ,原 ...

  9. open_basedir restriction in effect. File() is not within the allowed path(s)

    目前发现eaccelerator安装之后如果php.ini中设置open_basedir将导致open_basedir的一些报错(open_basedir restriction in effect. ...

随机推荐

  1. 15套精美的免费界面设计 PSD 素材【免费下载】

    在这个集合中,我们聚集15套精美的 PSD 界面设计模板,网页元素,用户界面​​工具包,扁平化图标,APP 应用程序 UI 设计的等等.这些来自优秀设计师的 PSD 源文件素材让其它的设计师们在设计用 ...

  2. Flatic – 超齐全的 Web 元素界面素材库免费下载

    Flatic 是一个庞大的用户界面工具包,包含数以百计的网页元素,这将有助于你在 Photoshop 中轻松设计整个网站.成套的图标和动作都已包含在套件中.该素材包包括超过100个 PSD 元素.您可 ...

  3. struts.xml中出现Package struts2 extends undefined package struts-default解决办法

    在struts.xml中出现extends undefined package struts-default,经过查阅资料原来是因为没有联网的缘故.这样解决:在myeclipse中关联本地的dtd文件 ...

  4. Struts2的基本流程的详细介绍

    Struts2基本流程 概述: Struts2框架由三部分构成:核心控制器.业务控制器和用户实现的业务逻辑组件.在这三部分中,struts2框架提供了核心控制器StrutsPrepareAndExec ...

  5. 计算几何 : 凸包学习笔记 --- Graham 扫描法

    凸包 (只针对二维平面内的凸包) 一.定义 简单的说,在一个二维平面内有n个点的集合S,现在要你选择一个点集C,C中的点构成一个凸多边形G,使得S集合的所有点要么在G内,要么在G上,并且保证这个凸多边 ...

  6. 组合数(Lucas定理) + 快速幂 --- HDU 5226 Tom and matrix

    Tom and matrix Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5226 Mean: 题意很简单,略. analy ...

  7. php获取textarea的值并处理回车换行的方法

    //注:\n是用双引号包的的,双引号!!双引号!!! explode("\n",$row[0]['value']

  8. mfc110.dll丢失,解决方法

    mfc110.dll下载_附文件使用方法 mfc110.dll是存放在windows系统中的一个重要dll文件,缺少它可能会造成部分软件或游戏无法正常运行.当系统提示“没有找到mfc110.dll”或 ...

  9. Window下生成OpenSSL自签证书

    :OPenSSL下载地址:https://www.openssl.org/source/ 编译好的OpenSSL下载地址: http://slproweb.com/products/Win32Open ...

  10. .NET Core创建一个控制台(Console)程序

    .NET Core版本:1.0.0-rc2 Visual Studio版本:Microsoft Visual Studio Community 2015 Update 2 开发及运行平台:Window ...