I want to read a file into an array in my PHP script. I run it locally on my Linux PC. There is a file /tmp/data.txt, a copy of it in /var/www/html/tmp/data.txt and the source file is in /var/www/html/script.php.
I have tried:
$dataArray = file('/tmp/data.txt');
but then PHP cannot open the file.
I have also tried: $dataArray = file('tmp/data.txt');
which worked fine overall, but I would like to use the file /tmp/data.txt.
How can I access the other File?
Advertisement
Answer
Your problem is probably that php isn’t allowed to read the /tmp folder. It creates its own folder. You might want to google for php rights on /tmp.