วิธีลบ Folder ที่ FTP ลบไม่ได้

บางครั้งเราไม่สามารถใช้ ftp ลบบาง Folder ได้เนื่องจาก FTP USER ไม่ได้เป็นเจ้าของ Folder นั้นๆ วิธีแก้ ต้องเข้าไปเปลี่ยน owner ของfolder นั้น แต่ถ้าไม่สามารถเปลี่ยน owner ได้จะทำอย่างไร ก็ใช้ php ลบได้ดังนี้ สร้างไฟล์ชื่อ del.php แล้วอัพโหลด จากนั้นรันไฟล์จาก browser

<?php
function deldir($dir){
$current_dir = opendir($dir);
while($entryname = readdir($current_dir)){
if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){
deldir("${dir}/${entryname}");
}elseif($entryname != "." and $entryname!=".."){
unlink("${dir}/${entryname}");
}
}
closedir($current_dir);
rmdir(${dir});
echo "ลบเสร็จแล้ว";
}
?>

<?
deldir("FOLDERที่ต้องการลบ");
?>
Div24Hr.COM
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.