kenny9239 Posted December 3, 2006 Share Posted December 3, 2006 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 More sharing options...
justsomeguy Posted December 4, 2006 Share Posted December 4, 2006 It might be the path, you have the wrong slash in there for a Windows filesystem. Other then that, make sure the path is correct. Is the test5.txt file showing up in the zip? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now