简体   繁体   English

¿php ftp_delete可以删除文件夹吗?

[英]¿php ftp_delete can remove folder?

The question is: can PHP ftp_delete() remove a folder? 问题是:PHP ftp_delete()删除文件夹吗? I have a process that uses ftp_delete() for removing ftp files but I fear I might accidentally remove a folder if the filename is empty. 我有一个使用ftp_delete()删除ftp文件的进程,但我担心如果文件名为空,可能会意外删除文件夹。

From the manual: 从手册中:

"ftp_delete() deletes the file specified by path from the FTP server." “ ftp_delete()从FTP服务器删除path指定的文件 。”

It doesn't delete a folder, rmdir() does. 它不会删除文件夹,而rmdir()会删除。

"rmdir — Removes directory" “ rmdir-删除目录”

Note: 注意:

Attempts to remove the directory named by dirname. 尝试删除以目录名命名的目录。 The directory must be empty, and the relevant permissions must permit this. 该目录必须为空,并且相关权限必须允许这样做。 A E_WARNING level error will be generated on failure. 失败时将生成E_WARNING级错误。

1.-You need to check the docs, the answer is there. 1.-您需要检查文档,答案在那里。

2.- http://php.net/manual/en/function.ftp-delete.php According to the docs, no. 2.- http://php.net/manual/en/function.ftp-delete.php根据文档,没有。 It says "files" not "files or folders", I think the final answer is no. 它说的是“文件”而不是“文件或文件夹”,我认为最终答案是“否”。

No, it cannot. 不,它不能。 You need to use ftp_rmdir to delete folders. 您需要使用ftp_rmdir删除文件夹。

http://php.net/manual/en/function.ftp-rmdir.php http://php.net/manual/zh/function.ftp-rmdir.php

Note: 注意:

The directory to delete. 要删除的目录。 This must be either an absolute or relative path to an empty directory. 这必须是目录的绝对路径或相对路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM