How to decompress zip files online with php_PHP tutorial

WBOY
Release: 2016-07-13 09:57:38
Original
896 people have browsed it

How to decompress zip files online with php

This article mainly introduces the method of decompressing zip files online with PHP, including relatively complete upload and zip decompression functions, which is of great practical value. Friends in need can refer to it

How to decompress zip files online with php_PHP tutorial

The example in this article describes how to decompress zip files online with php. Share it with everyone for your reference. The specific analysis is as follows:

In the php function library, I only found a zlib function that has something to do with compression. But what disappointed me was that it could not decode the zip file, but in the end I found a solution, which is through php The program execution function is used to implement this function, because there are so many things that can decode zip files now. If you don’t believe it, you can look for it where you can download the software. I guarantee you will not be disappointed. My words are not wrong. of.

The following is the original file of the program, the upload.php code is as follows:

<ol class="dp-j"><li class="alt"><span><span><table border=</span><span class="number">0</span><span> > </span></span></li><li><span> </span></li><li class="alt"><span><form enctype=multipart/form-data action=upsave.php method=post> </span></li><li><span> </span></li><li class="alt"><span><tr> </span></li><li><span> </span></li><li class="alt"><span><td>如果是*.zip的文件会被自动解压缩 </span></li><li><span> </span></li><li class="alt"><span><input name=myfile type=file size=<span class="number">50</span><span>> </span></span></li><li><span> </span></li><li class="alt"><span></td> </span></li><li><span> </span></li><li class="alt"><span></tr> </span></li><li><span> </span></li><li class="alt"><span><tr> </span></li><li><span> </span></li><li class="alt"><span><td colspan=<span class="number">2</span><span> align=center> </span></span></li><li><span> </span></li><li class="alt"><span><input type=submit value= 上传 <span class="keyword">class</span><span>=iwhite> </span></span></li><li><span> </span></li><li class="alt"><span><input type=reset value= 重填 <span class="keyword">class</span><span>=iwhite> </span></span></li><li><span> </span></li><li class="alt"><span></td> </span></li><li><span> </span></li><li class="alt"><span></tr> </span></li><li><span> </span></li><li class="alt"><span></table> </span></li><li><span> </span></li><li class="alt"><span></body> </span></li><li><span> </span></li><li class="alt"><span></html> </span></li><li><span> </span></li><li class="alt"><span>upsave.php代码如下: </span></li><li><span> </span></li><li class="alt"><span>代码如下: </span></li><li><span> </span></li><li class="alt"><span><?php </span></li><li><span> </span></li><li class="alt"><span><span class="comment">//保存上传的文件</span><span> </span></span></li><li><span> </span></li><li class="alt"><span>$filename=$myfile_name; </span></li><li><span> </span></li><li class="alt"><span>copy($myfile,$filename); </span></li><li><span> </span></li><li class="alt"><span>unlink($myfile); </span></li><li><span> </span></li><li class="alt"><span><span class="comment">//判断是否是zip文件</span><span> </span></span></li><li><span> </span></li><li class="alt"><span>$expand_name=explode(.,$filename); </span></li><li><span> </span></li><li class="alt"><span><span class="keyword">if</span><span>($expand_name[</span><span class="number">1</span><span>] == zip or $expand_name[</span><span class="number">1</span><span>] == zip) </span></span></li><li><span> </span></li><li class="alt"><span>{ </span></li><li><span> </span></li><li class="alt"><span>$str=pkunzip.exe -e $filename ; </span></li><li><span> </span></li><li class="alt"><span>exec($str); </span></li><li><span> </span></li><li class="alt"><span>unlink($filename); </span></li><li><span> </span></li><li class="alt"><span>} </span></li><li><span> </span></li><li class="alt"><span>> </span></li></ol>
Copy after login

I have tested the above program. It only needs to be placed on the server, but the directory must have write permissions, and a pkunzip.exe file must also be placed in the directory.

I hope this article will be helpful to everyone’s PHP programming design.



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/980581.htmlTechArticleHow to decompress zip files online with php. This article mainly introduces the method of decompressing zip files online with php, including more Complete upload and zip decompression functions, very practical value, friends who need it...
Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template