Jump to content

AtlasC1

Members
  • Posts

    38
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

AtlasC1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi everyone, I've been working on a Drupal-based Laboratory Information Management Systems (LIMS), and am having some issues with zipping files on the fly. It seems that, whenever the total content of the zip exceeds 85 MB, the download fails: the .zip file downloads, but is 0 bytes in size, and a .zip.download file also appears (which gives me the impression the download isn't complete). When I try extracting the .zip, it yields a .zip.cpgz file, which upon extracting, yields another .zip, and so on... Has anyone had an issue similar to this? Could it be timing out? It works fine for any number of files being zipped, as long as the total content is less than 85 MB (seems like the most random number ever). Here is the code that packages the files and sends them to the client: ... if ($filenames != "") { // Create temp zip file fwrite($log, "Generating unique zip filename... "); $tmp = tempnam("/birl/data/", "tempzip"); $tmp_zip = $tmp . ".zip"; fwrite($log, "[success]\n"); // We deliver a zip file header("Content-Type: archive/zip"); // The filename the client will see when downloading header("Content-Disposition: attachment; filename=bulk.zip"); // Zip the files into the tmp_zip file, note that we use very low // compression (1) to ensure rapid processing, and we get rid of paths (j), // so the zip contains only the files within those paths. fwrite($log, "Zipping files... "); $output = shell_exec("zip -0j $tmp_zip $filenames"); fwrite($log, "zip: "); fwrite($log, $output); fwrite($log, "[success]\n"); // Calc the length of the zip; needed for the progress bar of the browser $filesize = filesize($tmp_zip); header("Content-Length: $filesize"); // Keep a file pointer open, so we don't actually delete the file until the script is done $fp = fopen($tmp_zip, 'r'); // Clean up the tmp zip file fwrite($log, "Cleaning up... "); unlink($tmp); unlink($tmp_zip); fwrite($log, "[success]\n"); // Deliver the zip file fwrite($log, "Delivering to client... "); ob_clean(); flush(); fpassthru($fp); fwrite($log, "[success]\n"); } ... Note that if I comment out the calls to unlink and check the resulting .zip file, it is fully intact. So, it appears something goes wrong during the delivery process. Thanks!
×
×
  • 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.