tcsnguy08 Posted January 12, 2009 Share Posted January 12, 2009 I previously had this working, but now it's not. Can someone give me a suggestion as to why it gives me zip_close() expects parameter 1 to be resource, object given in /home/crescen9/public_html/uploadsongs.php on line 91 I haven't changed anything on this page except for the str_replace function, and it create the folder albums/albums/. etc. But, it doesn't create the zip archive here is the code. $zipobject = new ZipArchive(); $newbandname = @str_replace("'","'",$_SESSION['bandname']); $archivedir = "albums/albums/".$newbandname.$_SESSION['idno']."/"; if (!is_dir($archivedir)){ @mkdir($archivedir); } $archivename = $newbandname."_".$_SESSION['cdtitle'].".zip"; if ($zipobject->open($archivedir.$archivename, ZIPARCHIVE::CREATE) !== TRUE) { die ("Could not open archive"); } $n = 1; $x = $_SESSION['numtracks']; $directory = "radio/".$newbandname.$_SESSION['idno']."/"; while ($n <= $x){ $filename[$n] = $_SESSION['songs'][$n]; $zipobject-> addFile($directory.$filename[$n], $newbandname."_".$_SESSION['cdtitle']."/".$filename[$n]); $n++; } zip_close($zipobject); Thanks for any help you can provide. Link to comment https://forums.phpfreaks.com/topic/140439-solved-zip-file-help/ Share on other sites More sharing options...
premiso Posted January 12, 2009 Share Posted January 12, 2009 Where did you get the ziparchive class? Look for a method or property of the class that returns the ziparchive resource and call that inside the zip_close, or even maybe a close method of the ziparchive class and just call that instead of invoking the zip_close function. Link to comment https://forums.phpfreaks.com/topic/140439-solved-zip-file-help/#findComment-735012 Share on other sites More sharing options...
tcsnguy08 Posted January 12, 2009 Author Share Posted January 12, 2009 I got part of it from the PHP manual where they use ZipArchive () and I just rewroked to meet what I needed to do. I am trying what you suggested, I will give you an update. Thanks Link to comment https://forums.phpfreaks.com/topic/140439-solved-zip-file-help/#findComment-735016 Share on other sites More sharing options...
premiso Posted January 12, 2009 Share Posted January 12, 2009 http://us.php.net/manual/en/function.ziparchive-close.php Found that, use that instead. Link to comment https://forums.phpfreaks.com/topic/140439-solved-zip-file-help/#findComment-735020 Share on other sites More sharing options...
tcsnguy08 Posted January 12, 2009 Author Share Posted January 12, 2009 Thanks worked like a charm. Must be somewhere along the way I must've changed what I origanlly had, because it worked before. Thanks alot Link to comment https://forums.phpfreaks.com/topic/140439-solved-zip-file-help/#findComment-735022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.