View Full Version : How to check if file writing is enabled and enable if not

02-23-2012, 06:14 PM
As the title says, I'm trying to figure out how to check if a server has file writing enabled, and how to activate it if its not. I read through phpinfo but was unable to gleam which option I was looking for, and when I google, I seem to only find details on how to write files.

I'm not very good with server config, and my boss has no clue at all; any help would be appreciated.

I got to this because he wanted me to put up a wordpress install, but the server couldn't write the config file, nor edit the .htaccess, meaning I had to install it locally to find how the files should have been setup.

02-23-2012, 06:20 PM
Not being able to write to a file is a system permission issue. It's nothing PHP can solve. You'll either need to manually adjust the file via your CP or speak to your host about your default permissions.

02-23-2012, 06:54 PM
PHP can forbid file writing as well using combinations of things like safe mode and disable functions. Neither of these directives are enabled by default, and safe mode is gone in 5.4+.
Typically as tango says this is a filesystem permission issue, not one of PHP. You should either check if is_writable is true on a file, or attempt to open it in write mode to see if it fails.

02-23-2012, 08:24 PM
Yah, I found out the host defaults everything to 744... it makes sense, I just didn't realize it (the host I use defaults to 764), so it threw me off.