Alkimuz Posted January 17, 2012 Share Posted January 17, 2012 Hey, i'd like to extract filenames from my database and present them as a downloadable zip-file to my users. I found a usefull function on http://davidwalsh.name/create-zip-php and thought i could work that out to my needs, but on this function itself (before using it), i get an error.. on the following line: if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { i get: Parse error: syntax error, unexpected ')', expecting '(' i dont get it, dont think there is actually an error in the function.. does it mean that the php installed on the server i use, cant handle this function or anything? my phpinfo: http://dwarsfluit.davidvandiepen.nl/test.php the function is: <?php /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in... if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; } } } //if we have good files... if(count($valid_files)) { //create the archive $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach($valid_files as $file) { $zip->addFile($file,$file); } //debug //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } }?> thanks for helping! Link to comment https://forums.phpfreaks.com/topic/255250-php-create-zip-file-error/ Share on other sites More sharing options...
Alkimuz Posted January 17, 2012 Author Share Posted January 17, 2012 hmm.. i think more and more that it is indeed a server-issue.. i'll contact my hoster.. Link to comment https://forums.phpfreaks.com/topic/255250-php-create-zip-file-error/#findComment-1308729 Share on other sites More sharing options...
Stooney Posted January 17, 2012 Share Posted January 17, 2012 edit: nevermind, I don't know what I'm talking about here. Link to comment https://forums.phpfreaks.com/topic/255250-php-create-zip-file-error/#findComment-1308734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.