: This article describes how to use the fopen function in PHP to open a file and prompt that the permission is insufficient. if you are interested in the PHP Tutorial, refer to it. PHP fopen () function
Function definition and usage: fopen () functions open files or URLs.
Syntax:
Fopen (filename, mode, include_path, context)
The last two parameters are optional. we only use the first two parameters. the code is as follows:
The function implemented by the code is to open a file named newfile.txt in the previous example in the write-in format. if the file does not exist, try to create it. After opening the file, write the Hello World string to the file and close the file.
When there is no newfile.txt file under the folder, the following error occurs when you execute the above code:
Warning: fopen(newfile.txt): failed to open stream: insufficient permissions in
/Home/yums/web/blog_for_r & d/scripts/testOpen. php on line 3
Unable to open file!
Insufficient permissions? The most common problem in Linux is that you do not have the permission to create files on the hard disk? I tried to grant higher permissions to testOpen. php, so I executed the following command in terminal:
sudo chmod 666 testOpen.php
In this way, the PHP file has the permission to create the file. I will refresh the page and try again. WTF is still the problem!
Warning: fopen(newfile.txt): failed to open stream: insufficient permissions in
/Home/yums/web/blog_for_r & d/scripts/testOpen. php on line 3
Unable to open file!
After I created the file, I used gedit.pdf to create the newfile.txt file. So I executed the following command in terminal:
gedit newfile.txt
In this case, I have created a file, refreshed it, and got limited permissions. I also want to download the newfile.txt file and execute the following command in terminal:
ls -all
I found that the newfile.txtcreated with the upload script has only the read permission and no write permission. here is the question, so I can improve the write permission for the newfile.txt file:
sudo chmod 666 newfile.txt
Refresh the page now. no error is reported, and the corresponding string is written in the file.
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces the problem that PHP prompts insufficient permissions to open a file using the fopen function, including some content. I hope to help some friends who are interested in PHP tutorials.