Why on the server PHP execution file_put_contents to create a file back is false, the file directory has been set to 777 permissions, puzzled

Source: Internet
Author: User
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?
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.