Issues with PHP Creating file permissions under the server

Source: Internet
Author: User
PHP creates file permissions on the server
PHP Code
  
   $res = fopen ('/usr/local/asg/configs/meet.conf ', ' A + '); fclose ($res);

On the local machine if the meet.conf file does not exist, it can be created, but not on the server, with the LS command to see, there is no writable permission, so, in the code to add a judgment
PHP Code
  
   if (!is_writable ('/usr/local/asg/configs ')) {    system (' chmod 777/usr/local/asg/configs ');} $res = fopen ('/usr/local/asg/configs/meet.conf ', ' A + '); fclose ($res);

After the operation, still cannot create, again improved the next
PHP Code
  
   if (!is_writable ('/usr/local/asg/configs ')) {    system (' chmod 777/usr/local/asg/configs ');} System (' touch/usr/local/asg/configs/meet.conf ');

Run down, still not, again flexible, with putty Landing to the server, with the command line into the directory, directly with touch to create, I fork, useful, why the PHP file run will not be successful???


------Solution--------------------
I think you can use PHP function chmod to do this operation

Also, to give PHP a running account with this directory permission
------Solution--------------------
if (!is_dir ('/usr/local/asg/configs ')) {
mkdir ('/usr/local/asg/configs ');
chmod ('/usr/local/asg/configs ', 0777);
}
------Solution--------------------
For PHP does not have permissions to the directory, how can be given by PHP?

It's like you don't have the authority to go into the State Department, so you can't get into it unless you're looking for a relationship.
  • 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.