I tried to create a file using php and it will display a error
The php code is
$ourFileName = "testFile.txt";
$fh = fopen($ourFileName, 'w');
It says that the function doesnot has enough permission
You haven't specified any path for the file. So it should be trying to write file in the script directory, which may not have write access to the user which is running php (apache).
Make sure you provide a directory which is writable by webserver.
Make the file yourself where you want it, and chmod it properly.
Or if you need the script to be able to make new files (such as for logging things), you need to chmod the directory itself.
Thank you all for help. The problem was with CHMOD setting in my public_html directory. I fixed it. And at last also, thank you all
Changing the permissions of an important directory so anyone can write to it could be exploited by others.
The reason why the script can't create the file is because it's executed by the web server which is running as a different user that usually can't edit and delete files created by others (you included). By setting the /public_html directory's permission to 777, or allowing read/write/execute to all 3 groups, everyone can read/write every file in that directory, programs can be edited/deleted/created
The better solution is to create a subdirectory just for files to be created, uploaded file, set it's permission to 777 and use the directory in fopen, as in fopen('datafiles/testFile.txt', 'wb');