Cannot write to a PHP-created directory

更新时间:
复制 MD 格式

When you build a website on a Linux Web Hosting instance, your PHP program might automatically create a directory without write permission. As a result, you cannot write to that directory. This topic describes the cause and solution.

Symptom

You cannot write to a directory that is automatically created by a PHP program on your Linux Web Hosting instance.

Cause

By default, directories that are automatically created by a PHP program do not have write permission. You must enable the chmod function of PHP to grant write permission to the directory.

Solution

  1. Log in to the Web Hosting console.

  2. Find your Web Hosting instance and click Manage in the Actions column.

  3. In the left navigation bar, select Advanced Environment Settings > PHP.ini Settings.

  4. In the PHP Function Settings section of the PHP.ini Settings page, set the status of the PHP function chmod to Enabled.

  5. Click Save Settings.

  6. In the confirmation dialog box, click OK.

    After the changes are saved, the PHP Function Settings area shows that the chmod function is Enabled.

    Important

    Enabling the PHP chmod function exposes your website to attacks, which can cause slow response times or access errors. Consult your website service provider before performing this operation. To maintain security, disable the PHP chmod function when it is no longer needed.

  7. Verify that you can write to the directory automatically created by the PHP program.

    If the issue persists, submit a ticket.