How to use php to add a file to an existing zip file on the server. Note that the file is not generated. add a file without unlocking the zip file on the server. What should I do ., Add a zip module as follows: & lt ;? Php $ zip = newZipArchive (); $ filename = & quot;./test1 how to use php to add a file to an existing zip file on the server
Note that you do not need to generate a zip file. add a file without unlocking the server zip file. What should I do.
------ Solution --------------------
Add a zip module
The usage is as follows:
$ Zip = new ZipArchive ();
$ Filename = "./test112.zip ";
If ($ zip-> open ($ filename, ZIPARCHIVE: CREATE )! = TRUE ){
Exit ("cannot open <$ filename> \ n ");
}
$ Zip-> addFromString ("testfilephp.txt". time (), "#1 This is a test string added as testfilephp.txt. \ n ");
$ Zip-> addFromString ("testfilephp2.txt". time (), "#2 This is a test string added as testfilephp2.txt. \ n ");
$ Zip-> addFile ($ thisdir. "/too. php", "/testfromfile. php ");
Echo "numfiles:". $ zip-> numFiles. "\ n ";
Echo "status:". $ zip-> status. "\ n ";
$ Zip-> close ();
?>
------ Solution --------------------
I also want to say:
1. never blame others for not understanding. you can only blame yourself for not making it clear.
2. don't think you are always right. sometimes it's right to see if others are talking about it.
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.