Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chrispholt

macrumors regular
Original poster
Hi,

I was wondering if anybody could help me with a website I am making. I am quite capable of making websites (fairly simple ones) but know nothing about php and databases etc.

I have this test page, http://pastpapercentre.co.uk/test/coursetest.html and under the sub-heading "Pastpapers" there are is a listed of linked .pdf documents.

My website basically links documents from other websites, making it easy to access.

THE QUESTION

Is there an easy/simple way for me to make a download all button (like already on the site) compile all of the linked files into a .zip and then be presented as a download to the user. I will be making the website in a fairly "manual" manner, without databases.

So is there a way to make some sort of php script download all link files in one div or something? (complete long shot)

Any tips will be appreciated.

Thanks
 
You asked for simple, so I assume you only need the code necessary to create the zip archive and set the headers to start the download on the fly. Meaning, you know how to get the list of documents to add the zip.

http://roshanbh.com.np/2008/09/force-download-mutiple-files-zip-archive-php.html

Read that page and all comments there, download the source there and once you create your list pass it to the function something like this:

PHP:
$file_names=array('test.php','test1.txt');
$archive_file_name='zipped.zip';
$file_path=dirname(__FILE__).'/';
zipFilesAndDownload($file_names,$archive_file_name,$file_path);

That's pretty damned simple.

Up to you to add sensible code to deal with issues such as multi-user or sessions, checking paths, permissions, dealing with thousands of files, etc.

Note: PHP 5.2.0 or later to avoid installing a library to support ZIP

-jim
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.