php codeigniter ext,php – 如何读取codeigniter文件夹之外的文件

我有一个项目从外部codeigniter目录中读取文件,但在同一服务器中

例如:

codeigniter文件夹路径:

选择/ XAMPP / htdocs中/ yourprogramname /应用

但我想从以下文件中读取文件:

购买/仪表板/ FILENAME.TXT

我的代码:

$handle = fopen("purchase/dashboard/filename.txt", "r");

echo $handle;

?>

我怎么能在代码点火器中这样做?我知道如何从codeiginiter(应用程序中的文件夹资源/ etc)中的同一目录中读取文件但是当我尝试././或../ codeigniter不会读取文件内容时

解决方法:

You can use FCPATH

application

purchase

purchase > dashboard

system

index.php

文件

if (file_exists(FCPATH . 'purchase/dashboard/filename.txt') {

$handle = fopen(FCPATH . 'purchase/dashboard/filename.txt', "r");

echo $handle;

}

?>

要么

if (file_exists('/purchase/dashboard/filename.txt') {

$handle = fopen('/purchase/dashboard/filename.txt', "r");

echo $handle;

}

?>

Codeigniter路径函数定义

EXT: The PHP file extension

FCPATH: Path to the front controller (this file) (root of CI)

SELF: The name of THIS file (index.php)

BASEPATH: Path to the system folder

APPPATH: The path to the "application" folder

标签:php,path,codeigniter,readfile

来源: https://codeday.me/bug/20190627/1306396.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值