Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add to downloads button (non paying)

Status
Not open for further replies.

deepnthahouse

Technical User
Dec 17, 2006
4
US
I have a DJ only subscription website (written in php script), where record labels submit new and unheard music for member DJs' to rate, give feedback and promote at the clubs they work in. I want to make a add to downloads button where tracks can be "added to cart" one by one then a "download now" into a zip file. Does anyone know how this can be done. Thanks in advance...Deep
 
sure. it's basically a shopping cart: loads of these around on the web.

for the zip i'd advise using a system call (exec()) to zip the files and then use php to send the zip file to the browser. alternatively attach the files individually to an email and send it.

i've been fairly sure for some time that it might be possible to send multiple individual files to a client browser over http (rather than zipped). I posted something on this a couple of months ago hoping someone might take me up on the challenge but alas no one yet :(
 
Sure - just as jpadie said, a simple shopping cart is all you need - store all the files in an array which is ultimately stored in the SESSION.

Here is a php script I use for downloading multiple files as a zip. It uses the zip_lib.php that I found
Hope this helps.

Code:
<?php
include_once('zip_lib.php');
$zipfile = new zipfile();
for($i = 0; $i < count($file_list); $i++){
	$fdata = get_file_data($file_list[$i]); //a function to return contents of the file
	$zipfile->add_file($fdata, $file_list[$i]);
}
$filedata = $zipfile->file();

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Length: '.strlen($filedata));
header("Content-Transfer-Encoding: binary");
echo $filedata;
?>
 
@sleipnir214

nor I, old boy.

i was pondering a solution a while ago, when the question of zipping using the php library last came up (you provided the command line solution). i think that my posited solution depended on the browser being able to handle the multipart/message content description. at the time i thought that IE probably did and i have not followed it up since then. I'm almost persuaded by the implicit argument that since no-one has seen it done it must either be (i) impossible; (ii) impractical or (iii) unnecessary.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top