Three php Delete file code _php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.