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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
public function getArchivePCMFormated($numdossier, $path) {
$nomRepTravail = "tmpArchivePCM";
//$DIRECTORY_SEPARATOR = $DS = "/"; constante php
$fileToDelete = array();
try {
$this->flashMessage("test file_exists => $path");
if (!file_exists($path)){
$this->flashMessage("Archive Absente ! Veuillez contacter un administrateur");
throw new \Exception\NotFoundException();
}
/* *** creation rep travail extract **** */
$parentFolderPath = dirname($path, $levels = 1);
$workFolderPath = $parentFolderPath.DIRECTORY_SEPARATOR.$nomRepTravail;
if (!is_dir($workFolderPath)){
if (!mkdir($workFolderPath, 0777)){
$this->flashMessage("Creation Repertoire refusée Veuillez contacter un administrateur", self::DANGER);
throw new DomainException('Creation Repertoire refusée');
}
}
$this->flashMessage("workfolder =>".$workFolderPath);
/* *** extraction archive courante **** */
$zip = new \ZipArchive();
if ($zip->open($path, \ZipArchive::CREATE)){
$this->flashMessage("zip open");
//probleme sur le slash de fin de extractTo ???
echo("zip->extractTo(".$workFolderPath.DS.");");
if ($zip->extractTo($workFolderPath.DS)){
$this->flashMessage("zip extrait");
}else{ $this->flashMessage("ko extraction");}
$zip->close();
die();
}else{
$this->flashMessage("Impossible d'ouvrir l'archive \n Veuillez contacter un administrateur", self::DANGER);
throw new DomainException('Creation Archive refusée');
return false;
}
}
catch (Exception $ex) {
echo "<br/>","Exception ,", $ex->getMessage();
\Mvc\perso_trace($ex);
return false;
}
} |
Partager