Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 315509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:17:53+00:00 2026-05-12T08:17:53+00:00

I have set file permissions to 777 yet I cannot write to the file

  • 0

I have set file permissions to 777 yet I cannot write to the file with PHP.

I can clearly see in my FTP client that the file has 0777 permissions and when I do:

echo (true === is_writable('file.txt')) ? 'yes' : 'no';

I get ‘no’;

I also tried:

echo (true === chmod('file.txt', 0777)) ? 'yes' : 'no';

With the same result.

The directory listing goes something like this:

public_html
    public          0777
        css         0755
        js          0755
        file.txt    0777

And I’m using .htaccess file to redirect all traffic to the public subfolder. Of course, I have excluded the file from rewriting (it is accessible from the browser I checked):

RewriteRule  ^(file).*  - [L]

Why is that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:17:53+00:00Added an answer on May 12, 2026 at 8:17 am

    I guess Apache runs as a different user/group than the user/group owning the file. In which case, the file itself needs to be 0777.

    public only needs to be 0777 if you plan on adding files to the folder using PHP. Even if the folder itself is not 0777, if the file is and the folder has at least 5 for the user (read/execute), you should be able to write to the file.

    In the end, your file tree should look like this:

    public_html
        public
            file.txt  0777
    

    Naturally, you won’t be able to change those permissions using PHP, but you can do so from your FTP client.

    If it still isn’t working, PHP might be running in safe mode or you might be using an extension such as PHP Suhosin. You might get better result changing the owner of the file to the same user/group that is running the script.

    To get the user/group id of the executing user, you may use the following:

    <?php
    echo getmyuid().':'.getmygid(); //ex:. 0:0
    ?>
    

    Then, you may use chown (in the terminal) to change the owner of the file:

    > chown 0:0 file.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of Berkeley DB files on my Linux file system that
I have a file in cvs that has Sticky Options set to -kk .
I have a .ico file that is embedded as a resource (build action set
I have long recognized that any set of whitespace in an HTML file will
I have a client-side security policy, with a statement that grants permissions. I want
I have created a Python file to generate a Mandelbrot set image. The original
I have set up a Django application that uses images. I think I have
HI all I have a question regarding file permissions. I have created a log
We have set up a system where notifications get sent to a user with
I have set a canvas' background to an image of a company logo. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.