Home > Article > Software Tutorial > How to compress zip format files?
The editor of php has a new method to compress files in zip format. Compressing files is a common operation to save storage space and facilitate transmission. By using PHP's ZipArchive class, you can easily compress files and folders. First, create a ZipArchive object, then add the files or folders to be compressed, and finally call the close() method to save and close the compressed file. This method is simple, easy to understand, effective and fast, allowing you to compress files easily!
Compressing zip files usually requires the use of decompression software, such as WinRAR and 7-Zip. Next, we'll detail how to do this.
1. Use WinRAR decompression software
1. Install and open the WinRAR decompression software, find and select the files or folders that need to be compressed through the directory bar, and then click the menu tab [Add].
2. After the [Compressed File Name and Parameters] page pops up, select the "ZIP" format in the [Compressed File Format] area, and then modify the compressed file name as needed, or select the saving directory of the compressed file through the [Browse] option. .
You can also set other options. For example, if you want to protect the zip file from being viewed at will, you can click [Set Password] to set an "open password" for the zip file.
If the file is too large, you can also create a zip volume compressed file. Fill in the size of each volume in the [Split into volumes, size] column, and the file will be compressed into multiple zip volumes. document.
After completing all option settings, click [OK] to compress the file into a zip package.
2. Use 7-zip decompression software
1. Install and open the 7-zip decompression software, find and select the files or folders that need to be compressed, and then click the menu tab [Add].
2. After popping up [Add to compressed package], you can set relevant options as needed.
For example, the file name of the compressed package and the saving directory; if you want to protect the file, enter the password in the [Password] area to set the "open password" after compression; if you want to create a volume, enter the [Volume Size] , Bytes] column to enter the volume size you want to set. After the settings are completed, click [OK] to compress the file into a zip archive.
It should be noted that if a password is set when compressing the zip file, remember to remember or save the password, because if you forget the password, you cannot view or decompress the zip file, whether it is WinRAR or 7-zip decompression software Neither has a "forgot password" option.
To solve this problem, we might as well try other zip-related tools. Taking Pepsi Niu ZIP Password Recovery Tool as an example, it can help us retrieve the "open password" of zip compressed files or zip volume compressed files.
The tool provides 4 retrieval methods. If the forgotten password is a zip compressed file, you can directly import the file into the tool, then select the appropriate method and follow the prompts; if it is a zip compressed file, you need Merge the sub-volume files into a zip file and then import it into the tool.
The above is the detailed content of How to compress zip format files?. For more information, please follow other related articles on the PHP Chinese website!