Jump to content

Create a zip file that includes *.doc and *.jpg


kenny9239

Recommended Posts

Hi guysI am trying to create a zip file under PHP by using code like this////////////////////////////////////////////////////////////////////<?php$zip = new ZipArchive();$filename = $_SERVER['DOCUMENT_ROOT']."/test"."/test112.zip";if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("cannot open <$filename>\n");}$zip->addFromString("test1.txt" . time(), "#1 This is a test string added as testfilephp3.txt.\n");$zip->addFromString("test2.txt" . time(), "#2 This is a test string added as testfilephp4.txt.\n");$zip->addFile('c:/test3.doc','new.doc');$zip->addFile('c:/test4.jpg','new1.jpg');$zip->addFile('c:/test5.txt','new2.txt');echo "numfiles: " . $zip->numFiles . "\n";echo "status:" . $zip->status . "\n";$zip->close();?> ////////////////////////////////////////////////////////////////// After the zip file was created, I extracted it.(there is a failure message during the extraction), when i open the extracted file, i found the test3.doc and new1.jpg are not there, but all the .txt files are there.How can i add the non .txt files into my zip file in PHP?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...