简体   繁体   中英

PHP: how extract a zip file?

Is it possible to extract a zip file stored in server using php file operations. The zip file has to be unzipped, I know the location of the file inside server so how can the file will be used for the process. Note- Users don't upload any data they just gives the different textual information which is stored as a zip file and it cannot be used to store in database.

Edit1-can we give html's input tag a DEFAULT PATH of file which has to be uploaded so user will not have to select a file they will just need to press upload button

$zip = new ZipArchive;

$res = $zip->open('file.zip');

if ($res === TRUE) 
{
    $zip->extractTo('/extract_path/');
    $zip->close();
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM