Aller au contenu

Do you support Zip files with PHP?

Ce contenu n’est pas encore disponible dans votre langue.

Yes. PHP on Ruachost hosting supports Zip archives.

The zip extension gives you the ZipArchive class. Your scripts can use it to:

  • Create .zip files, for example to let visitors download several files at once.
  • Read the contents of a Zip file.
  • Extract uploaded Zip files.

Many applications rely on it. WordPress, for example, uses it to install plugins and themes from .zip files.

<?php
$zip = new ZipArchive();
if ($zip->open('archive.zip', ZipArchive::CREATE) === true) {
$zip->addFile('report.pdf');
$zip->close();
}

If you get a “Class ZipArchive not found” error

Section titled “If you get a “Class ZipArchive not found” error”
  1. Log in to cPanel.
  2. Open Select PHP Version.
  3. Click Extensions and make sure zip is ticked.

See Changing PHP versions and settings using PHP Selector.

Cette page vous a-t-elle aidé ?