Home Backend Development PHP Tutorial php处理文件的小例子(解压缩,删除目录)_PHP

php处理文件的小例子(解压缩,删除目录)_PHP

Jun 01, 2016 pm 12:08 PM
delete directory unzip

复制代码 代码如下:
$dir =   './temp';
$desc   =   'tar_test.tar.gz';
system("tar   czvf   $desc   $dir");   //压缩
//system("tar   zxvf   $desc"); //解压  

function d_rmdir($dirname) {   //删除非空目录 
if(!is_dir($dirname)) { 
    return false; 

$handle = @opendir($dirname); 
while(($file = @readdir($handle)) !== false){ 
   if($file != '.' && $file != '..'){ 
      $dir = $dirname . '/' . $file; 
      is_dir($dir) ? d_rmdir($dir) : unlink($dir); 


closedir($handle); 
return rmdir($dirname) ; 


if(d_rmdir("./temp")) 
   echo "succes"; 
else 
   echo "false"; 
?>
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to unzip files on Windows 11 How to unzip files on Windows 11 Oct 11, 2023 pm 09:09 PM

If you don't know how to unzip files on Windows 11, you may not be able to install certain software or view files that others have sent you in archive format. This process is very simple to perform, and in today's guide we will show you the best way to do it on Windows 11. How to unzip files in Windows 11? 1. Find the zip file on your PC using the context menu and right-click on it. Next, select "Extract All." Select the extraction location and click the "Extract" button. Wait for Windows to extract the files. 2. Use a third-party tool to download WinZip and install it. Double-click the zip file you want to extract. Now click Extract to and select the destination folder. 3.

How to decompress files in Xunlei for free How to decompress files for free How to decompress files in Xunlei for free How to decompress files for free Mar 12, 2024 pm 03:04 PM

When we use this platform, we can use the method of free decompression of files, so that we can open some compressed packages we downloaded, and of course there are many files, etc., which can be understood directly from the above. Obtained, many users may not know much about this, so this also allows us to better use some functions. This is also more convenient for us when downloading other files in the future. It can be used better, and the effect is still good, so today I will bring you a variety of completely different usage effects. Why haven’t you come to know about such a useful function? For those of you who don’t know it yet, Friends, hurry up and take a look at some of the strategy explanations below. You can’t miss this excitement.

How to decompress files with 7-Zip software - How to set and cancel the password for compressed packages with 7-Zip software​ How to decompress files with 7-Zip software - How to set and cancel the password for compressed packages with 7-Zip software​ Mar 18, 2024 pm 05:25 PM

7-Zip is not only a completely free open source decompression software, but its decompression function is also very powerful and can support compression operations on videos, documents, folders, pictures and other files. So how does 7-Zip software decompress files? How to set and cancel the password for compressed packages in 7-Zip software? Let the editor give you the answer below! How to compress files with 7-Zip: 1. Open the 7-Zip software, select the file or folder that needs to be compressed, and then click the [Add] option in the menu. 2. When the window pops up, select the format of the compressed file, and then click [OK] below to compress. How to decompress compressed files with 7-Zip: 1. Open the 7-Zip software, select the compressed package to be decompressed, and then click [Extract] in the menu

How to compress and decompress data in MySQL? How to compress and decompress data in MySQL? Jul 30, 2023 pm 01:43 PM

MySQL is a widely used relational database management system that supports data compression and decompression functions. In large-scale data storage and processing, data compression can significantly reduce storage space usage and improve data transmission efficiency. This article will introduce how to implement data compression and decompression in MySQL, and give corresponding code examples. 1. Compressed data MySQL provides a variety of compression algorithms, such as LZ4, Zlib, Snappy, etc. In MySQL5.7.17 and later versions, In

Centos 7 compression and decompression command overview Centos 7 compression and decompression command overview Dec 31, 2023 pm 09:02 PM

1.Zip file compression syntax: zip plus the compressed file name plus the file name to be compressed. [root@localhost~]#ziptest.ziptest.txtadding:test.txt(deflated100%)[root@localhost~]#The percentage number of the progress bar appearing after it indicates that it has been compressed. Then you can verify it in ll to see if it has your name. file package. [root@localhost~]#llTotal usage 820004-rw-------.1rootroot1587 March 2216:58anaconda-ks.cfg-rw-r--r--.1ro

In-depth understanding of file compression and decompression technology in Java development In-depth understanding of file compression and decompression technology in Java development Nov 20, 2023 pm 02:10 PM

In-depth understanding of file compression and decompression technology in Java development. With the rapid development of the Internet and the rapid changes in information technology, large amounts of data exchange and transmission have become the norm in today's society. In order to store and transmit data efficiently, file compression and decompression technology came into being. In Java development, file compression and decompression is an essential skill. This article will deeply explore the principles and usage of this technology. 1. Principles of file compression and decompression In computers, file compression is to compress one or more files using a specific algorithm.

What is the compression software that comes with win10? What is the compression software that comes with win10? Dec 23, 2023 pm 10:19 PM

When many users use the Windows 10 operating system, they will inevitably have questions about whether each function of this version includes a dedicated decompression program. In response to this, I will use the specific system of Windows 1064-bit Home Chinese Edition as an example to show you the reason. Does win10 have its own decompression software? Answer: No. Although Win10 system performs well in various functions, it does not come with pre-installed decompression software. Perhaps many users mistakenly think that the decompression software they usually use is called "WinRAR", and thus misunderstand that this software comes from Microsoft. In fact, the "WinRAR" application software is not a product developed by Microsoft, but an independent APP. Some pirated systems

How Redis implements data compression and decompression functions How Redis implements data compression and decompression functions Nov 07, 2023 pm 04:27 PM

Redis is a high-performance in-memory database commonly used for caching and data storage. In terms of data storage, Redis provides compression and decompression functions, which can effectively save memory space and improve data storage and transmission efficiency. This article will introduce how Redis implements data compression and decompression functions, and give specific code examples. The data compression and decompression functions in Redis are implemented through some parameters in the configuration file. In the default configuration file redis.conf of Redis, you can find the following

See all articles