有谁做过上传文件自动压缩的东东 - PHP进阶讨论

现在PHP 有提供压缩成ZIP格式的??但是压缩后都是无法打开的难道是没压缩成功?要对上传的文件进行判断?或者能压缩成RAR格式的 或更好的有做过的,请教请教。。。
2026年09月23日 10:04
有2个网友回答
网友(1):

Zip是通用的,rar不通用用ZipArchive类就行了$zip = new ZipArchive();$filename = \"./test112.zip\";if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {? ? exit(\"cannot open \\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(\"../test/10_while_break_continue.avi\", uniqid().\".avi\");echo \"numfiles: \" . $zip->numFiles . \"\\n\";echo \"status:\" . $zip->status . \"\\n\";$zip->close();

网友(2):

原帖由 于 2008-6-11 14:53 发表 [i][/url]exec....... [/b]???指?。。。