Jump to content

[SOLVED] zip file help!!!


tcsnguy08

Recommended Posts

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("&#39","'",$_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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.