Below I have collected three php delete files Oh, he can use unlink delete any can delete files, this program to delete files, pictures, compressed files, etc., we use several methods to instance
Below I have collected three PHP tutorial delete files Oh, he can use unlink Delete any can delete files, this program to delete files, pictures, compressed files, etc., we use several methods to instance.
Three kinds of PHP delete file code
if ($od =opendir ($d))//$d is the directory name
{
while (($file =readdir ($od))!==false)//www.zhutiai.com reads the files in the directory
{
Unlink ($file); $file is the file name
}
}
To understand these three PHP functions: Opendir () Readdir () unlink ()
File Deletion code two system call method
function Del_dir ($dir)
{
if (Strtoupper (substr (php_os, 0, 3) = = = ' Win ') {
$str = "rmdir/s/q". $dir;
} else {
$str = "Rm-rf". $dir;
}
}
File Deletion code three
$info = "A123"; Directory Name
if (Is_dir ($info)) {
if (RmDir ($info)) {
echo "Directory {$inof} delete complete www.bkjia.com";
}else{
echo "Directory cannot be deleted! The reason--probably the file still exists under the directory! ";
}
}
if (Is_file ($info)) {
if (unlink ($info)) {
echo "File {$info} deleted ...!";
}else{
echo "File {$info}mb.php100.com delete failed ...! Attempt to modify file permissions delete ... ";
if (chmod ($info, 0777)) {
Unlink ($info);
echo "File {$info} permissions modified after deletion ...";
}else{
echo "File {$info} cannot be deleted by the web, it is possible that FTP permissions have been set for this file ...";
}
}
}
Recently found a lot of sites reproduced this site file, note Please add this site connection, thank you for your cooperation!
http://www.bkjia.com/PHPjc/444838.html www.bkjia.com true http://www.bkjia.com/PHPjc/444838.html techarticle below I have collected three php delete files Oh, he can use unlink delete any can delete files, this program to delete files, pictures, compressed files, etc., we have used several methods to real ...