Bilmem birisi bir zip dosyaları (sunucu tarafı) yapmak için bu kütüphaneyi kullanırsanız. Burada benim kodunu görebilirsiniz:
$i=0;
while ($row = mysql_fetch_array($query, MYSQL_NUM)) {
$title[$i]=$row[1]." - ".$row[2];
// i remove some chars, because they can create confusion with the filesystem
$titleontxt=$title[$i];
$title[$i]=str_replace("/", "", $title[$i]);
$title[$i]=str_replace(":", "", $title[$i]);
$title[$i]=str_replace("*", "", $title[$i]);
$title[$i]=str_replace("?", "", $title[$i]);
$title[$i]=str_replace('"', "", $title[$i]);
$title[$i]=str_replace("<", "", $title[$i]);
$title[$i]=str_replace(">", "", $title[$i]);
$title[$i]=str_replace("|", "", $title[$i]);
$title[$i]=str_replace(",", "", $title[$i]);
$trackid=$row[0];
mkdir("./temp/".$_SESSION['nickname'], 0700);
$file = fopen("./temp/".$_SESSION['nickname']."/".$title[$i].".txt", "w");
$fwrite = fwrite($file, $titleontxt."\r\n");
$j=0;
$fwrite = fwrite($file, "\r\n single side");
$fwrite = fwrite($file, "\r\n there is a single line");
fclose($file);
$i++;
}
include_once("./lib/pclzip.lib.php");
$data=date("Y-m-d");
$zipstring="./temp/".$_SESSION['nickname']."/".$trackid."-GTW-Tracklist.zip";
$filezip=new PclZip($zipstring);
for($i=0; $i<sizeof($title); $i++) {
// inserisce i txt nel file zip
$v_list = $filezip->add("./temp/".$_SESSION['nickname']."/".$title[$i].".txt", PCLZIP_OPT_REMOVE_ALL_PATH);
if ($v_list == 0) {
die("Error : ".$filezip->errorInfo(true));
}
}
for($i=0; $i<sizeof($title); $i++) {
unlink("./temp/".$_SESSION['nickname']."/".$title[$i].".txt");
}
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$zipstring");
header("Content-Description: Backup");
header("Content-Length: ".filesize($zipstring));
readfile($zipstring);
unlink($zipstring);
rmdir("./temp/".$_SESSION['nickname']);
exit;
Ben bu kütüphaneyi kullanmaya çalıştığınızda Neyse, ben 2 sorunları var:
1 - Ben bir zip yapmak gerektiğinde, i / temp / username adlı bir klasör oluşturmak için kullanabilirsiniz. Sonra, ben bu zip olun. I istemcide dosyayı göndermek firefox yandan, bu zip dosya adı sözdizimi _temp_username_filename.zip başındaki ekleyin. Neden bu?
2 - i, zip indir i açın, ve ben bu dosyanın içine txt açın. I kapattığınızda, winrar i yeni "veri" eklemek isterseniz bana sormak, ama herhangi bir veri eklemek gerekmez. Ben sadece açık ve yakındır. Neden?
Ben, onun garip bir soru biliyorum, ama belki birisi aynı sorunları vardı! Şerefe