Hi. Dunno if someone use this library to make (server-side) a zip files. Here you can see my code :
$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;
Anyway, when i try to use this library i have 2 problems :
1 - when i need to make a zip, i use to create a folder called /temp/username . Then, i make that zip. On firefox, when i send the file at the client, it add at the begin of the zip-file name the syntax _temp_username_filename.zip. Why this?
2 - i download the zip, i open it, and i open the txt into this file. When i close it, winrar ask to me if i want to insert new "data", but i don't add any data. I just open and close. Why?
I know, its a strange question, but maybe someone had the same problems! Cheers