Mám skript, ktorý mi uploadne zip súbor a extraktuje ho, lenže extract nie vždy funguje. Ak mám taký kód tak mi zip extract nefunguje a vypiše chybovú hlášku Warning: ZipArchive::extractTo() [ziparchive.extractto]: SAFE MODE Restriction in effect. The script whose uid/gid is 5599/5518 is not allowed to access /var/www/clients/client13/web101/web/img/gallery owned by uid/gid 33/33 in /var/www/clients/client13/web101/web/admin/gallery.php on line 63
Kód:
<?php
$original = $_POST["original"];
$dir = "../img/$original";
mkdir($dir, 0777);
if($_FILES["zip_file"]["name"]) {
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
$type = $_FILES["zip_file"]["type"];
$name = explode(".", $filename);
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
foreach($accepted_types as $mime_type) {
if($mime_type == $type) {
$okay = true;
break;
}
}
$continue = strtolower($name[1]) == 'zip' ? true : false;
if(!$continue) {
$message = "Chyba";
}
$target_path = $dir.$filename;
if(move_uploaded_file($source, $target_path)) {
include("Zip.php");
$zip = new ZipArchive();
$x = $zip->open($target_path);
if ($x === true) {
$zip->extractTo($dir);
$zip->close();
unlink($target_path);
}
$message = "Chyba.";
} else {
$message = "Chyba.";
}
}
?>
Avšak ak dám takýto kód už to funguje
Kód:
<?php
$original = $_POST["original"];
$dir = "../img/";
mkdir($dir, 0777);
if($_FILES["zip_file"]["name"]) {
$filename = $_FILES["zip_file"]["name"];
$source = $_FILES["zip_file"]["tmp_name"];
$type = $_FILES["zip_file"]["type"];
$name = explode(".", $filename);
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
foreach($accepted_types as $mime_type) {
if($mime_type == $type) {
$okay = true;
break;
}
}
$continue = strtolower($name[1]) == 'zip' ? true : false;
if(!$continue) {
$message = "Chyba";
}
$target_path = $dir.$filename;
if(move_uploaded_file($source, $target_path)) {
include("Zip.php");
$zip = new ZipArchive();
$x = $zip->open($target_path);
if ($x === true) {
$zip->extractTo($dir);
$zip->close();
unlink($target_path);
}
$message = "Chyba.";
} else {
$message = "Chyba.";
}
}
?>
Lenže problém je v tom, že ja to potrebujem tak ako to je v prvom kóde, aby som to potom mohol rozoznať, v ktorej galerii sú tie obrázky. Ako to mám urobiť, aby mi to fungovalo ?