Har prøvet at få det her til at virke i laaaaaang tid, kan bare ikke. Så tænkte på om der var nogen her inde der kunne hjælpe. Jeg bruger denne ZIP funktion http://php.net/manual/en/book.zip.php
Her er min kode: (/Gør som Thomas!/)
Index.php:
Kode: Vælg alt
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form action="php.php" method="get">
<label for="imgo">Img1: <input type="checkbox" name="imgo" id="imgo" value="1" /></label><br />
<label for="img2">Img2: <input type="checkbox" name="img2" id="img2" value="1" /></label><br />
<input name="submit" type="submit" value="submit" />
</form>
<?php
include("php.php");
?>
</body>
</html>
Kode: Vælg alt
<?php
if (isset($_GET['submit'])) {
if (isset($_GET['imgo'])) {
$files_to_zip = array(
'img/1858682429_133.jpeg'
);
$result = create_zip($files_to_zip,'test');
}
}
function create_zip($files = array(),$destination = '/zips',$overwrite = true) {
if(file_exists($destination) && !$overwrite) { return false; }
$valid_files = array();
if(is_array($files)) {
foreach($files as $file) {
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
if(count($valid_files)) {
$zip = new ZipArchive();
if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
foreach($valid_files as $file) {
$zip->addFile($file,$file);
}
$zip->close();
return file_exists($destination);
}
else
{
return false;
}
}
?>