Php decompress the rarfile code
There are many examples of zip files online. it is not directly supported to decompress the rarfile php. you can use pecl Download the corresponding version of the non-thread-safe dll to the http://pecl.php.net/package/rar Then, it is thrown to the php ext directory. Open php. ini. Add a row Extension = php_rar.dll Restart the web server and php
- 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 );
-
- }
|
Php, rar