Php decompress the rarfile and zip file. There are many examples of zip files on the internet. it is not directly supported to decompress the rarfile php. you can use pecl to pecl. php. netpackagerar downloads the corresponding version of the non-thread-safe dll and then throws it to the zip file network for many examples. the rarfile unzipping php is not directly supported, you can use pecl to download the corresponding version of the non-thread-safe dll to the http://pecl.php.net/package/rar and then drop it into the php ext directory.
Open php. ini.
Add a row
Extension = php_rar.dll
Restart the web server and php
The code is as follows:
Public function _ unzip ($ fileName, $ extraceid ){
$ FileName = iconv ('utf-8', 'gb2312', "upload/zip/August .rar ");
// Echo $ fileName .'
';
$ Extractings = "upload/zip/TEST /";
$ Rar_file = rar_open ($ fileName) or die ('could not open rar ');
$ List = rar_list ($ rar_file) or die ('could not get list ');
// Print_r ($ list );
Foreach ($ list as $ file ){
$ Pattern = '/\".*\"/';
Preg_match ($ pattern, $ file, $ matches, PREG_OFFSET_CAPTURE );
$ PathStr = $ matches [0] [0];
$ PathStr = str_replace ("\" ",'', $ pathStr );
// Print_r ($ pathStr );
$ Entry = rar_entry_get ($ rar_file, $ pathStr) or die ('
Entry not found ');
$ Entry-> extract ($ extraceid); // extract to the current dir
}
Rar_close ($ rar_file );
}
Download the corresponding version of the non-thread-safe dll and then throw it...