dongxiezhi9564 2016-07-27 07: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 10: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条)

报告相同问题?

悬赏问题

  • ¥20 修改中兴光猫sn的时候提示失败
  • ¥15 java大作业爬取网页
  • ¥15 怎么获取欧易的btc永续合约和交割合约的5m级的历史数据用来回测套利策略?
  • ¥15 有没有办法利用libusb读取usb设备数据
  • ¥15 为什么openeluer里面按不了python3呢?
  • ¥15 关于#matlab#的问题:训练序列与输入层维度不一样
  • ¥15 关于Ubuntu20.04.3LTS遇到的问题:在安装完CUDA驱动后,电脑会进入卡死的情况,但可以通过键盘按键进入安全重启,但重启完又会进入该情况!
  • ¥15 关于#嵌入式硬件#的问题:树莓派第一天重装配置python和opencv后第二天打开就成这样,瞎捣鼓搞出来文件夹还是没把原来的界面调回来
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥20 Arduino 循迹小车程序电路出错故障求解