Why on the server PHP execution file_put_contents create file return is false, the file directory has been set to 777 permissions, puzzled
To use file_get_contents to read the picture file on the network and write it to the server locally by file_put_contesnts, File_get_contesnts performs no problem, reads the information, and then $data the data that is read out:
Var_dump (file_put_contents ($local _file_position, $data)), var_dump information is displayed in the test, but finally file_put_contents return is false, Do not know why, in the internet search said is Aparche no write permission, is this? If yes, how do you set it up?
Environment: CentOS 6.5 + MySQL5.5.35 + tomcat7.0.47
------Solution--------------------
Do you use absolute or relative paths?
------Solution--------------------
Verify that the data obtained by file_get_contents () is present and that the data type is valid.
------Solution--------------------
The estimate is insufficient authority
Echo substr (sprintf ('%o ', fileperms (' your directory ')),-4); Let's see what happens.
------Solution--------------------
Reference:
absolute path and relative path are the same
The directory where the file is required to write is also required to have write permission.
Like/home/centos/123.txt.
Directory home, CentOS is also required to write permissions not only 123.txt need Write permission
------Solution--------------------
File_put_contents a clear error message output when a failure occurs
Please post the
------Solution--------------------
The tips are clear,
Permission denied
Access Denied
------Solution--------------------
You're going to write the file in the/usr/local/www/wxtest/txt directory.
Please check that the directory exists and is writable
------Solution--------------------
1.755 permission refers to Rwxr-xr-x, which has no write permission for the same group and other users. 777 All users have all permissions.
2. It is recommended to use absolute path, before writing the file in the script to determine whether the path exists, does not exist the first to create a path (directory) and then write the file, this is a bloody lesson.
------Solution--------------------
Set/usr/local/www/wxtest/txt to 777.
------Solution--------------------
Are you sure that the permissions for the out-of-group users are 777?