thinkphp清空全部目录(包括子目录)
thinkphp清空所有目录(包括子目录)
在admin项目的Common目录下common.php文件: /** * 删除xml目录下的所有xml文件 * string $fp 文件路径(不包括文件名) * string $fn 文件名称(包括扩展名) * boolean $type 是否关联到所有子目录 */ function delXML($type=true,$fn='',$fp='./xml'){ if(!is_dir($fp)){ return 'nodir'; //被删除目录不存在 }else{ if(!is_empty_dir($fp)){//如果不是空的 $H = @ opendir($fp); while(false !== ($_file=readdir($H))){ //检索目录 if(is_dir($fp."/".$_file) && $_file != "." && $_file!=".." && $_file!=="Thumbs.db"){ if($type){ if(!is_empty_dir($fp.'/'.$_file)){//如果不是,调用自身,不过是原来的路径+他下级的目录名 delXML($type,$fn,$fp."/".$_file); } if(is_empty_dir($fp.'/'.$_file)){//如果是空就直接删除 rmdir($fp.'/'.$_file); } } //检索文件 }else if(is_file($fp."/".$_file) && $_file!="." && $_file!=".." && $_file!=="Thumbs.db"){ if(eregi('/'.$file,'/'.$_file)){ if(!unlink($fp.'/'.$_file)){ return false; //删除失败 } } } } closedir($H); } return true; //删除失败 } } //判断目录是否为空,true为空,false为不空 function is_empty_dir($fp) { $H = @ opendir($fp); $i=0; while($_file=readdir($H)){ $i++; } closedir($H); if($i>2){ return false; }else{ return true; } } 调用方法: 在admin项目的Action目录下SiteMapAction.class.php文件: class SiteMapAction extends Action { //删除全部xml目录地图文件 function delXML(){ $flag = delXML(); exit($flag); } } 静态页面ajax方法: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="../Public/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/artDialog/artDialog.min.js"></script> <title>删除目录文件</title> </head> <body> <script language="javascript"> function delXML(){ if(!window.confirm('确定要删除整站地图吗?')){ return; } var testDialog; testDialog = art.dialog({ lock: false, title:'', id:'loaddialog', content:'<font color="#ff0000">正在删除中...</font>', width:220 }); var url="{:U('delXML')}"; $.get(url,null,function(data){ //$("#con").append(data); testDialog.close(); if(data == true){ alert('删除成功!'); }else if(data == false){ alert('删除失败,请稍候再试...'); }else if(data == 'nodir'){ alert('错误:被删除目录不存在'); } }); } </script> <input name="delete" type="button" class="agin agn" value="全删除" onClick="javascript:return delXML();"/> </body> </html>
?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

Use Java's File.length() function to get the size of a file. File size is a very common requirement when dealing with file operations. Java provides a very convenient way to get the size of a file, that is, using the length() method of the File class. . This article will introduce how to use this method to get the size of a file and give corresponding code examples. First, we need to create a File object to represent the file we want to get the size of. Here is how to create a File object: Filef

How to convert php blob to file: 1. Create a php sample file; 2. Through "function blobToFile(blob) {return new File([blob], 'screenshot.png', { type: 'image/jpeg' })} ” method can be used to convert Blob to File.

The usage of return in C language is: 1. For functions whose return value type is void, you can use the return statement to end the execution of the function early; 2. For functions whose return value type is not void, the function of the return statement is to end the execution of the function. The result is returned to the caller; 3. End the execution of the function early. Inside the function, we can use the return statement to end the execution of the function early, even if the function does not return a value.

Use Java's File.renameTo() function to rename files. In Java programming, we often need to rename files. Java provides the File class to handle file operations, and its renameTo() function can easily rename files. This article will introduce how to use Java's File.renameTo() function to rename files and provide corresponding code examples. The File.renameTo() function is a method of the File class.

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Source code: publicclassReturnFinallyDemo{publicstaticvoidmain(String[]args){System.out.println(case1());}publicstaticintcase1(){intx;try{x=1;returnx;}finally{x=3;}}}#Output The output of the above code can simply conclude: return is executed before finally. Let's take a look at what happens at the bytecode level. The following intercepts part of the bytecode of the case1 method, and compares the source code to annotate the meaning of each instruction in
