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

  • SEARCH
  • Home
  • 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 6817313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:02:14+00:00 2026-05-26T21:02:14+00:00

I have googled but I can’t seem to get my script to work. this

  • 0

I have googled but I can’t seem to get my script to work.

this is my code

if (is_dir("tmp")) {
    if (substr(sprintf("%o", fileperms("tmp")), -4) == "0777") {
        echo "good";
    } else {
        echo "going to chmod the tmp folder to 777";
        if (!chmod("tmp", octdec(0777))) { // tried chmod("tmp, 0777) too
                echo "Oops, I couldn't chmod the /setup/tmp directory, please do this manually";
        }
    }
} else {
    echo "we'll make the folder";
}

I can’t seem to get the chmod to work, i read somewhere that if register globals was off then this wouldn’t work(i have that setting set to off).

I followed the PHP.net manual and some of the examples they provided there in the user comments, as well as some stack-overflow posts that i found relevant. but perhaps i need to tweak some php settings to get this to work?

Is there a way to get the chmod function to work without needing to change the PHP.ini?

  • 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-26T21:02:15+00:00Added an answer on May 26, 2026 at 9:02 pm

    You haven’t given us enough information to determine why chmod() is failing. It could be that the web-server doesn’t have sufficient privileges to alter directory permissions.

    The owner of the web-server process should own the directory or be a member of the owning group. For example, if root owns tmp, and your web-server is running as the user ‘apache’, it will not be possible to modify the directory’s permissions from PHP.

    I believe the settings you mention in php.ini are for debugging, not magically ‘fixing’ chmod. Try prepending the following lines of code to your PHP script and you should get more useful debug output:

    ini_set('display_errors', 'On');
    error_reporting(E_ALL)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am struggling to get this simple PowerShell script to work. I have googled,
I have searched this site and also googled but can't seem to find the
I've googled this but can't get a straight answer. I have a mysql database
i have googled in the last 3 hours but i can't seem to find
I have googled this topic but i can't find any tutorial that i can
I have tried different ways but no success. Googled but can not find this
I've have gone through stackoverflow for days and googled a lot but can still
I know this question can be answered by searching in google. But I have
I have Googled merge+cell+Javascript but did not find any suitable code to implement merge
I am new to Emacs. I have googled this but no good answer there.

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.