Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将用户上传的文件压缩到某个位置。虽然上传部分有效,但我不知道如何压缩文件。我可以创建一个 zip,但现在不知道如何将其实际保存到磁盘。
只需在创建 zip 时将所需的目标路径传递给它:
$path = 'path/to/file.zip'; $zip = new ZipArchive(); $zip->open($path, ZipArchive::CREATE); // add contents... $zip->close();
这肯定会帮助你......这些是2个解释清楚的例子希望它有帮助..
http://www.9lessons.info/2012/06/creating-zip-file-with-php.html
http://davidwalsh.name/create-zip-php