Download empty folder structure maybe as a zip file

I’m creating a job sheet web app. I would like an empty folder and subfolder structure to be created automatically and then downloaded to the desktop - then users will drag files into these folders before saving them to a local server - only because we can’t upload very large artwork files to our webserver.

I can get PHP to create the folders and subfolders using mkdir.

But now I want to serve them automatically from the jobsheet app as a download to desktop. The only way I think this is possible is by zipping up the folders using this:


<?PHP
// increase script timeout value
ini_set('max_execution_time', 300);

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

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

// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("app/"));

// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
    $zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");        
}

// close and save archive
$zip->close();
echo "Archive created successfully.";    
?>

However, it doesn’t seem to be working - is this because the folders and subfolders are all empty?

Or it could be because the PHP is pointing to the wrong folder? Can anyone explain the relationship between the location this PHP script is saved and the app folder that the “app/” address the script currently points to. They currently resides in the same root folder.

Short of that I’m stumped!! :doh: