简体   繁体   中英

how to zip by exec command line through php

I have a ubuntu server. How can I zip files through executing a command line to zip from my php script

I want to zip the file because the file sizes are too big and zipping it through php will cause more load on server.

Thank You.

如果您不需要压缩,我建议您查看tar而不是zip,因为它应该更快,并且将导致与zip相同的一个文件,但不占用CPU时间来处理存档

$exec = `usr/bin/zip -v zipfile filetozip filetozip2 filetozip3`

The -v is for verbose mode - if you want to check whether the zip worked you can print that out or log it or whatever. Your files will be found in zipfile.zip in the directory from where you ran the command.

exec,system,fork,-您可以使用任何命令来帮助您执行具有不同控制级别(阻止,非阻止)的命令行程序

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM