Forum Moderators: coopster
unlink() fails permanently under php/windows with a 'permission denied' error; this is despite all privileges being adequate. It seems that it is caused by the readonly flag, which is permanently set on Windows XP folders, where it means something completely different (a problem which the various posts on the net, including Microsoft's KB, do not help to resolve). My best guess is that the php unlink() function verifies this flag and does not even attemp the operation.
So, when all else had failed, I had to design a workaround. Fortunately, it works fine:
if ($windows_environment)
exec("DEL /F/Q \"$filepath\"", $lines, $errno);
else
$errno = unlink($filepath);
A similar solution works for directories, using the Windows RD command.
Be sure to quote the $filepath in the exec command, otherwise file paths which have spaces in them will cause to command to fail.
I hope this helps.
But I concur that a greater help would be for the php team to realize that this problem is real and to fix it.