Jump to content

creating zip file dynamically


mrsburnside

Recommended Posts

This code works: 

 

// create object
$zip = new ZipArchive();

// open archive 
if ($zip->open('./download/zipfile.zip', ZIPARCHIVE::CREATE) !== TRUE) {
    die ("Could not open archive");
}

 

but, I want to create the name of the zip file dynamically.  The following code does not work ... doesn't give me an error, just doesn't create the zip file:

 

/

/ create object
$zip = new ZipArchive();
$thisTime = time();

// open archive 
$thisZip = './download/'.$thisTime.'_download.zip';
$thisZip_b = $thisTime.'_download.zip';
if ($zip->open($thisZip, ZIPARCHIVE::CREATE) !== TRUE) {
    die ("Could not open archive");
} 

 

thanks in advance oh wise ones.

 

mrsburnside

 

Link to comment
https://forums.phpfreaks.com/topic/210890-creating-zip-file-dynamically/
Share on other sites

The next things I would try are:

 

1.  Can I create a file with that name manually?

2.  Can I create a file called "1281999572_download.zip" without generating it automatically with time(), instead using a static string?

3.  If it still doesn't work, try filenames with different lengths and with different character sets in the filenames.

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.