Even if safe mode is activated on the server, if script file, target file and parent folder is owned by the same user, fopen should work without any problem. Any ideas why this is happening?
The files have 755 permission.
Thank you for your time and effort.
$filename="file.html";
echo "Current User: ".get_current_user()."; UID: ".getmyuid()."; GID: ".getmygid()."<br/>";
echo "Current PID: ". getmypid() . "<br/>";
echo "Parent folder owner: ". fileowner(".") . "<br/>";
echo "$filename owner: " . fileowner($filename) . "<br/>";
echo "Current folder is writable: " . is_writable($filename);
OUTPUT:
Current User: vnnamp; UID: 32024; GID: 32026
Parent folder owner: 32024
file.html owner: 32024
Current folder is writable: false
Are you sure your script is operating in the correct directory?
If it is not then the file name you pass it likely doesn’t exist and that would be why
is_writable()returns false. Usegetcwd()to print out the directory the script is operating in (can set it withchdir()) or use absolute file names.EDIT: Just to summarize the discussion below:
$_SERVER['DOCUMENT_ROOT']: Nopecheck mismatch file owner and process user with
posix_getpwuid(posix_geteuid()): Yes, cause of the problem