2012-06-11 44 views
2

我试图取消链接本地版本的网站上的文件夹。不允许操作 - 在本地机器上取消链接

我得到的错误:

operation not permitted 

任何想法如何,我可以得到断开链接到我的本地机器上运行?我使用MAMP。

+0

“本地机器”是什么意思? *客户*或*服务器*? – deceze

+0

在上传到服务器之前,我正在测试本地计算机上的网站。 – panthro

+2

请复制您获得的**确切**错误消息。 – ThiefMaster

回答

6

documentation

unlink — Deletes a file

See Also: rmdir() - Removes directory

你有一个目录。您需要使用rmdir,而不是unlink

+0

此外,该目录需要为空,感谢您的帮助! – panthro

1

这意味着脚本不允许删除该文件夹。这可能有多种原因 - 最有可能的原因是您正尝试使用unlink()文件夹而不是使用rmdir()来删除它。

以下是“操作不允许”(EPERM)从unlink(2)手册页可能的原因:

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) .

0

这是一个权限问题。

先给你想取消链接的权限一样CHMOD 666

您可能创建的文件自己的文件,并希望PHP(其他用户再自己,大概Apache或www数据取决于如何安装MAMP)删除为你的文件 - 没有正确的权限,这是不能做到的。

+1

为什么你想要*可执行文件*位来删除文件?我知道它在PHP世界中非常常见,只需将所有应该可以通过PHP脚本(通常以apache用户身份运行)写入的内容写入,但写入权限就足够了。实际上,您只需要在父文件夹上写入权限 - 文件本身可以由任何人拥有,并且只要您可以写入该文件夹并且没有粘性位,就具有任何权限。 – ThiefMaster

+0

@ThiefMaster这只是一个坏习惯......我通常自己使用CHMOD 666,但我明白你的观点。更新了我的答案。 – Repox

相关问题