Is there a way to compress/archive a folder in the server using php script to .zip or .rar or to any other compressed format, so that on request we could archive the folder and then give the download link
Thanks in advance
Is there a way to compress/archive a folder in the server using php script to .zip or .rar or to any other compressed format, so that on request we could archive the folder and then give the download link
Thanks in advance
PHP comes with the ZipArchive extension, which is just right for you.
Beware of a possible problem in Adnan's example: If the target myarchive.zip is inside the the source folder, then you need to exclude it in the loop, or to run the iterator before creating the archive file (if it doesn't exist already). Here's a revised script that uses the latter option, and adds some config vars up top. This one shouldn't be used to add to an existing archive.
Here is an example: