Self-editing and emptying remote Web space weapon

Source: Internet
Author: User
Tags learn php

Learn PHP filesystem, using its functions, you can easily bulk delete files and folders of remote server.
but must be careful, delete the wrong, regret yo!


Application Scenario: When we test some projects remotely, we do not need to delete, so as not to waste space, but also to prevent loopholes. But using FTP to delete very slowly, so upload this file, set up the folder you want to delete, directly run this URL is done!

[code= "PHP"]<?php

//php recursively delete directories and files
function Delall ($path) {
if (!is_dir ($path)) {
return false;
        }
//Open Directory
$DH = Opendir ($path);
//Cyclic reading of directories
While (($file = Readdir ($DH))!== false) {
//filter out the current directory '. ' and up-level directory ' ... '
if ($file = = '. ' | | $file = = ' ... ') continue;
//If the file is a directory, enter the recursive
if (Is_dir ($path. ' /'. $file)) {
Delall ($path. ' /'. $file);
} else {
//If it is not a directory, delete it
unlink ($path. ' /'. $file);
        }
    }
//After exiting the loop (all files have been deleted at this time), close the directory and delete
Closedir ($DH);
rmdir ($path);
return true;
}

$path = './aa ';
Var_dump (Delall ($path));
[/code]


Original article:http://bbs.51cto.com/thread-1501963-1.html Welcome to come to discuss!

This article is from the "Colorful Pole" blog, please be sure to keep this source http://qicaiji.blog.51cto.com/1158325/1941642

Self-editing and emptying remote Web space weapon

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.