Ci-dessous, les différences entre deux révisions de la page.
| webdev:php:zip [22/10/2016 17:46] – créée dolo | webdev:php:zip [22/10/2016 19:11] (Version actuelle) – dolo | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ====== Compression et décompression d' | ||
| + | [[https:// | ||
| + | < | ||
| + | <?php | ||
| + | // increase script timeout value | ||
| + | ini_set(" | ||
| + | // create object | ||
| + | $zip = new ZipArchive(); | ||
| + | // open archive | ||
| + | if ($zip-> | ||
| + | { | ||
| + | die (" | ||
| + | } | ||
| + | // initialize an iterator | ||
| + | // pass it the directory to be processed | ||
| + | $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(" | ||
| + | // iterate over the directory | ||
| + | // add each file found to the archive | ||
| + | foreach ($iterator as $key=> | ||
| + | { | ||
| + | if($key != " | ||
| + | { | ||
| + | $zip-> | ||
| + | } | ||
| + | } | ||
| + | // close and save archive | ||
| + | |||
| + | echo "--- SAUVEGARDE DU DOSSIER ---< | ||
| + | echo " | ||
| + | $msg = $zip-> | ||
| + | echo " | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Ce code fonctionne bien, mais il créé des fichiers vides _ et __ dans chaque dossier à cause des emplacements " | ||