How to make download an entire folder?
Posted: Sun Jul 19, 2009 1:11 pm
I have images sorted into folders, and I want users to have the option of downloading the entire folder full of images to their computer.
Is this possible to do with PHP?
I've found some scripts to force download single files, but not entire folders full of files.
This is the file downloading script I have
I have tried making the $file variable the name & location of the folder, ex:
I get a download with the proper name, however, it is 0 bytes in size.
Is this possible to do with PHP?
I've found some scripts to force download single files, but not entire folders full of files.
This is the file downloading script I have
Code: Select all
<?php
$file = "filename.ext";
// Quick check to verify that the file exists
if( !file_exists($file) ) die("File not found");
// Force the download
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Length: " . filesize($file));
header("Content-Type: application/octet-stream;");
readfile($file);
?>Code: Select all
$file = "records/folder001";