无法通过ftp php脚本删除目录/文件夹。
我在php日志中收到一个奇怪的警告,并且ftp_delete函数不起作用。请看下面
PHP日志说:
PHP警告:ftp_delete():在第29行的C:\ Hosting \ HYPV \ website.com \ wwwroot \ Services \ TestDelete.php中结束
<?php
require('../FTPconfig.php');
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id,true);
$contents = ftp_nlist($conn_id, "/FTP/website.com/wwwroot/Clients/clientName/Reports/");
if ($contents == true) {
foreach ($contents as $file) {
$local_file = $file;
$server_file = '/FTP/website.com/wwwroot/Clients/clientName/Reports/'.$file;
ftp_delete($conn_id, $server_file); //<------------------- PHP LOG says: ftp_delete(): End in C:\Hosting\HYPV\website.com\wwwroot\Services\TestDelete.php on line 29
}
} else {
echo "No files available.";
}
ftp_close($conn_id);
?>
答案 0 :(得分:0)
感谢Barmar,我知道了。我需要先清空目录的内容,然后再使用 ftp_rmdir 函数删除目录。 ftp_delete无法正常工作...