http://seabova.com/zip.php
/home/content/s/e/a/seabova/html/idxphotos.zip
Warning: fopen(/538368a.jpg) [function.fopen]: failed to open stream: Permission denied in /home/content/s/e/a/seabova/html/zip.php on line 34
Hello , I 'd like from a php script to be able to unzip to extract an archive.
This is the script :
<?php
function mkdir_recursif($dir) {
$parties = preg_split('#/' . preg_quote(DIRECTORY_SEPARATOR) . '#', $dir, -1, PREG_SPLIT_NO_EMPTY);
$base = '';
foreach ($parties as $p) {
if (!file_exists($base . $p)) {
mkdir($base . $p);
}
$base .= $p . DIRECTORY_SEPARATOR;
}
}
function extractTo($archive, $destination, $ecrase = FALSE, $fichiers = NULL) {
if (($zip = zip_open($archive)) === FALSE) {
die(var_dump($zip));
return FALSE;
}
if (!file_exists($destination)) {
mkdir_recursif($destination);
}
while ($entree = zip_read($zip)) {
$fichier = zip_entry_name($entree);
if (is_array($fichiers) && !in_array($fichier, $fichiers)) {
continue;
}
if (zip_entry_open($zip, $entree)) {
$contenu = zip_entry_read($entree, zip_entry_filesize($entree));
zip_entry_close($entree);
if ($ecrase !file_exists($destination . DIRECTORY_SEPARATOR . $fichier)) {
if (strpos($fichier, '/') !== FALSE) {
mkdir_recursif($destination . DIRECTORY_SEPARATOR . dirname($fichier));
}
$fp = fopen($destination . DIRECTORY_SEPARATOR . $fichier, 'w');
fwrite($fp, $contenu);
fclose($fp);
}
} else {
zip_close($zip);
return FALSE;
}
}
zip_close($zip);
return TRUE;
}
$path = '/home/content/s/e/a/seabova/html/idxphotos.zip';
echo $path;
# Exemples d'utilisation
# Extraction de l'ensemble des fichiers qui composent l'archive
extractTo( $path, '');
/*
$path = '/home/content/s/e/a/seabova/html/idxfullphotos.zip';
extractTo( $path, '');
*/
?>
On my localhost, it works well (windows XP + easyphp) but not on my host.
zip.php is chmoded 777 as are also the folders idxphotos and idxfullphotos so I don't get it.
thanks for your help.