Reputation: 461
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
Upvotes: 1
Views: 367
Reputation: 2398
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. Use getcwd()
to print out the directory the script is operating in (can set it with chdir()
) or use absolute file names.
EDIT: Just to summarize the discussion below:
$_SERVER['DOCUMENT_ROOT']
: Nopeposix_getpwuid(posix_geteuid())
: Yes, cause of the problemUpvotes: 2
Reputation: 9260
The result of is_writable() function is cached. Try clearing it with clearstatcache()
Upvotes: 0
Reputation: 1448
If the user is the owner of the file, it does not mean file should be writable by the user. It may have permissions like 0444 or so.
Upvotes: 0