我有一个项目从外部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
文件
<?php
if (file_exists(FCPATH . 'purchase/dashboard/filename.txt') {
$handle = fopen(FCPATH . 'purchase/dashboard/filename.txt', "r");
echo $handle;
}
?>
要么
<?php
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