Dean Huang Dean Huang - 1 month ago 6
PHP Question

how to read file outside codeigniter folder

i have a project to read file from outside codeigniter directory but in the same server

example :

codeigniter folder path:


but i want to read file from :


my ussual code :

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


how could i do this in code igniter? i know how to read file from the same directory in codeiginiter (folder resource/etc in application) but when i tried ././ or ../ codeigniter wont read the file content

Answer Source

You can use FCPATH


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