dongxiezhi9564 2016-07-26 23:31
浏览 459
已采纳

require_once(PHPExcel / Classes / PHPExcel.php):无法打开流

I am trying to include PHPExcel to a Silverstripe 3 site to export excel sheets. Right now I am just trying to test, but I get this error when trying to do it:

[Warning] require_once(/sitename/mysite/AddOns/PHPExcel/Classes/PHPExcel.php): failed to open stream: No such file or directory

Thing is I know this file exists since I copied it over myself and have rechecked the path over and over. So I decided "well check if the file exists" using this code:

    if(!file_exists(Director::baseURL().'mysite/AddOns/PHPExcel/Classes/PHPExcel.php')) {
        echo 'sdf';exit;
}

The path is correct (that is where it is saved) according to the error, but- file does not exist. I am also requiring the file in the same way, with no luck

require_once Director::baseURL().'mysite/AddOns/PHPExcel/Classes/PHPExcel.php';

I have tried everything-checking file permissions, referencing parent folders using ../../, calling it directly like AddOns/PHPExcel, moving it to this new AddOns folder (first tried placing the PHPExcel classes on the root and discovered that Silverstripe doesn't read it then :) )

I know I am doing something wrong but for the life of me I cannot see what. Please help

Thanks

  • 写回答

3条回答 默认 最新

  • ds3422222 2016-07-27 02:25
    关注

    BASE_PATH is the best way to access the web root folder.

    require_once(BASE_PATH . '/AddOns/PHPExcel/Classes/PHPExcel.php');
    

    Also this is only an issue if you are not using composer, to solve this issue in the correct way you should use composer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 加热反应炉PLC控制系统设计(相关搜索:梯形图)
  • ¥15 python 用Dorc包报错,我的写法和网上教的是一样的但是它显示无效参数,是什么问题
  • ¥15 经过滑动平均后的一维信号还原用什么结构好呢?
  • ¥15 指定IP电脑的访问设置
  • ¥30 matlab ode45 未发现警告,但是运行出错
  • ¥15 为什么devc++编译项目会失败啊
  • ¥15 vscode platformio
  • ¥15 代写uni代码,app唤醒
  • ¥15 全志t113i启动qt应用程序提示internal error
  • ¥15 ensp可以看看嘛.
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部