I was trying fopen
for my project. Which running on Ubuntu with CodeIgniter PHP framework. The result was like this:
A PHP Error was encountered
Severity: Warning
Message: fopen(testFile.txt): failed to open stream: Permission denied
Filename: controllers/home.php
Line Number: 10
can't open file
By the way, here are my code on Controller:
public function create_file(){
$ourFileName = 'testFile.txt';
$ourFileHandle = fopen($ourFileName, 'r') or die ("can't open file");
fclose($ourFileHandle);
}
I looked at that code, and I thought that there is should be a path where I open the file, right? If yes, where should I put the path? Because, I followed this code from this tutorial: http://www.tizag.com/phpT/filecreate.php.
One thing that make me confuse is, there is no file testFile.txt
and I wanna create it, but how to give the permission to create it. Because terminal will say No such file or directory for the file
. What should I do?
I've also tried to run the chmod
on www
directory. But, it still didn't work.
Hope anyone help me to handle this problem. Thank you...