search
Homephp教程php手册php教程:如何解压压缩包

php教程:如何解压压缩包

Jun 06, 2016 pm 08:09 PM
phpHostcompressionhowTutorialUnzip

有时候啊,看到一个主机蛮不错的说,然后一冲动,你就买下来。买下来发现控制面板功能弱爆了,连个在线解压的功能都没有,那真的叫一个后悔

有时候啊,看到一个主机蛮不错的说,然后一冲动,你就买下来。买下来发现控制面板功能弱爆了,连个在线解压的功能都没有,那真的叫一个后悔啊。确实,在线解压缩可以非常便捷地完成部署网站数据的一个任务,如果文件多又大,那先上传再在线解压肯定要更快的,虽说并不是什么必备功能,但是如果缺失了这个功能,那真是不方便。主机上禁用了这个或者没有这个功能的话,那我们手动地添加这个功能吧。

php解压函数

<?php ? ??
function?unzip($location,$newLocation){? ??
????????if(exec("unzip?$location",$arr)){? ??
????????????mkdir($newLocation);? ??
????????????for($i?=?1;$i<?count($arr);$i++){? ??
????????????????$file?=?trim(preg_replace("~inflating:?~","",$arr[$i]));? ??
????????????????copy($location.'/'.$file,$newLocation.'/'.$file);? ??
????????????????unlink($location.'/'.$file);? ??
????????????}? ??
????????????return?TRUE;? ??
????????}else{? ??
????????????return?FALSE;? ??
????????}? ??
????}? ??
?>??

使用方法

if(unzip('zipedfiles/test.zip','unziped/myNewZip'))? ??
????echo?'解压成功!';? ??
else? ??
????echo?'未知原因?错误鸟';???

声明: 本文采用 BY-NC-SA 协议进行授权 | IT路人
转载请注明转自《php教程:如何解压压缩包》

Statement
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 Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.