File Manager Won't Download Multiple Files on Windows ( zip )

Permalink
If you have been experiencing 0K downloads of zip files when attempting to download multiple files at once from the file manager. Here is the fix.

First visit:http://info-zip.org/ and download zip.exe and unzip.exe and make sure they are in your path and the IUSR_'yourservernamehere' account has execute permissions on them. I just create a bin directory inside of inetpub and add this to path. In order for IIS to pick up the path change you must do an iisreset(remember to run cmd as administrator) or reboot server. Alternatively, specify full path to exe's below.

Second, modify you site.php file to include this:

define('DIR_FILES_BIN_ZIP', 'zip.exe');
define('DIR_FILES_BIN_UNZIP', 'unzip.exe');

Third, and unfortunately this required a small mod to a core file. I didn't try the normal hiding mechanism because I was lazy, you should try that first. But anyway, alter \concrete\tools\files\download.php

around line 28ish depending on your c5 version

from

if (!in_array(basename($f->getPath()), $filenames)) {
            $files .= "'" . addslashes($f->getPath()) . "' ";
         }
         $f->trackDownload();
         $filenames[] = basename($f->getPath());
      }
   }
   exec(DIR_FILES_BIN_ZIP . ' -j \'' . addslashes($filename) . '\' ' . $files);


to

if (!in_array(basename($f->getPath()), $filenames)) {
            if(ON_WINDOWS){
               $files .= ' "' . addslashes($f->getPath()) . '"';
            }
            else{
               $files .= "'" . addslashes($f->getPath()) . "' ";
            }
         }
         $f->trackDownload();
         $filenames[] = basename($f->getPath());
      }
   }
   if(ON_WINDOWS){
      exec(DIR_FILES_BIN_ZIP . ' -j "' . addslashes($filename) . '"' . $files . '2>&1');
   }


the problem being a lack of zip executables on windows by default and in code the command line formatting of the quotes was messing up the external call out.

This was on Windows 2008, IIS7, and PHP 5.4

I imagine something similar to this may affect importing zipped files into the file manager as well. You should be able to extrapolate a solution for that from this post.

I hope this helps someone save some time.

-H

Hackopotamus