How to add a file to a zip file that the server already exists with PHP

Source: Internet
Author: User
Tags ziparchive
How to add a file to a zip file that the server already exists with PHP
Note that instead of generating a zip, add a file inside without unlocking the server zip file. May I ask how I should do it.

------Solution--------------------
Add a zip module in.
Use the following methods:

$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--------------------
Also want to say:
1, never blame others do not understand, can only blame themselves did not speak clearly.
2, do not think that they are always right, and occasionally look at others are not said is also right.
  • 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.