Php reads zip files (delete files, Extract files, and add files) instances,

Source: Internet
Author: User
Tags ziparchive

Php reads zip files (delete files, Extract files, and add files) instances,

<? Php/* php extracts files from a zip compressed file */$ zip = new ZipArchive; if ($ zip-> open('jqueryfive-screen scrolling corner code .zip ') = TRUE) {// The ANSI encoded format of the Chinese file name $ zip-> extraceid ('foldername '); // extract all files // $ zip-> extraceid ('/my/destination/dir/', array('pear_item.gif ', 'testfromfile. php '); // extract some files $ zip-> close (); echo' OK ';} else {echo 'failed';}?> <? Php/* The http://www.manongjc.com/article/1341.htmlphp removes files from a zip file */$ zip = new ZipArchive; if ($ zip-> open('ajaxupload.zip ') = TRUE) {$ zip-> deleteName('file.txt '); // delete the file $ zip-> deleteName ('testdir/'); // Delete the folder $ zip-> close (); echo 'OK';} else {echo 'failed';}?> <? Php/* http://www.manongjc.com/article/1342.htmlphp Add a file to a zip file */$ zip = new ZipArchive; if ($ zip-> open('ajaxupload.zip ') = TRUE) {// ajaxupload.zip is an existing zip file. Pay attention to the encoding of Chinese file names. $ zip-> addFile ('33. xml '); // Add a new file $ zip-> close (); echo' OK ';} else {echo 'failed';}?>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.