Reputation: 24099
Im trying to unlink a folder on the local version of my site.
I get the error:
operation not permitted
Any ideas how I can get unlink to work on my local machine? Im using MAMP.
Upvotes: 6
Views: 25445
Reputation: 15475
This is a permissions problem.
Try giving the file you want unlink permissions like CHMOD 666.
You probably created the file yourself and want PHP (another user then yourself, probably Apache or www-data depending on how MAMP is installed) to delete the file for you - without the right permissions, this cannot be done.
Upvotes: -1
Reputation: 318808
It means the script is not allowed to delete the folder. This can have various reasons - the most likely one is that you are trying to unlink()
a folder instead of using rmdir()
to delete it.
Here are the possible reasons for "operation not permitted" (EPERM) from the unlink(2)
man page:
EPERM The system does not allow unlinking of directories, or unlinking of directories requires privileges that the calling process doesn't have. (This is the POSIX prescribed error return
; as noted above, Linux returns EISDIR for this case.)
EPERM (Linux only) The file system does not allow unlinking of files.EPERM or EACCES The directory containing pathname has the sticky bit (S_ISVTX) set and the process's effective UID is neither the UID of the file to be deleted nor that of the directory containing it, and the process is not privileged
(Linux: does not have the CAP_FOWNER capability).
Upvotes: 2
Reputation: 944559
See the documentation:
unlink — Deletes a file
and
See Also: rmdir() - Removes directory
You have a directory. You need to use rmdir
, not unlink
.
Upvotes: 17