Bonjour,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 // Adding files to a .zip file, no zip file exists it creates a new ZIP file // increase script timeout value ini_set('max_execution_time', 5000); // create object $zip = new ZipArchive(); // open archive if ($zip->open('my-archive.zip', ZIPARCHIVE::CREATE) !== TRUE) { die ("Could not open archive"); } // initialize an iterator // pass it the directory to be processed $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("../class")); // iterate over the directory // add each file found to the archive foreach ($iterator as $key=>$value) { $zip->addFile(realpath($key), realpath($key)) or die ("ERROR: Could not add file: $key"); } // close and save archive $zip->close(); echo "Archive created successfully.";
j'ai trouve ce bout de script sur le net bien pratique.
Cependant, quand je l'applique a un dossier, j'ai une archive corrompue en resultat. Le message est :
Avez vous deja rencontre ce probleme ou avez vous simplement une idee ?fin de l'archive incorrect
D'avance merci.
Partager