One thing you can do to make the file readable / writable is to call this function upon file / folder creation without the second argument:
function AutoChmod($path, $chmod = null)
{
if (file_exists($path) === true)
{
if (is_null($chmod) === true)
{
$chmod = (is_file($path) === true) ? 644 : 755;
if (in_array(get_current_user(), array('apache', 'httpd', 'nobody', 'system', 'webdaemon', 'www', 'www-data')) === true)
{
$chmod += 22;
}
}
return chmod($path, octdec(intval($chmod)));
}
return false;
}
Example:
AutoChmod('/path/to/file/you/just/created.txt');
This function will give appropriate permission whether you are working with SuPHP / SuExecPHP or not.
To check permissions you just need to use the functions is_readable()
and is_writable()
.