download more than one file at a time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sharyn
Forum Commoner
Posts: 33
Joined: Tue Jun 15, 2004 6:39 pm
Location: So Cal

download more than one file at a time

Post by sharyn »

I'm looking to find a way to download multiple files at a time. I've got my user to a page where they can check multiple boxes and then click the "download these files(s)" button. Now what I'd to happen is that the files all download into some predetermined area (the user will have no choice as to where things get to download to)

I can't seem to google any kind of script to do this. Does anyone here know of a way to do this? Thanks in advance to all that answer :D

- sharyn
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

You cant force a file onto the user's machine, given that kind of ability some developer could write a script to download a virus to a users machine without their permission.
For multiple file downloads you could have each download open in a new window, for example when they check file 1 and file 2 the following code gets run:

use javascript to open download.php?file=1 and download.php?file=2 so they get 2 pop up windows

then download.php:

Code: Select all

<?php
header('Content-type: image/jpg'); // put the correct mime type for the file
output("$path/$img.jpg"); // put the path to the file
?>
Last edited by josh on Mon Nov 08, 2004 6:36 pm, edited 1 time in total.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

you could zip the files.

i know ive seen a few classes that make zipping files on the fly really easy.
User avatar
sharyn
Forum Commoner
Posts: 33
Joined: Tue Jun 15, 2004 6:39 pm
Location: So Cal

Post by sharyn »

jshpro2 & rehfeld,

Both answers sound pretty doable... let me see what I can do with them... Zipping sounds good since it's all one download and it would be a smaller file that they might possibly recieve than a lot of larger ones... I'll start googling php zipping. Thanks a mill you two :D

- sharyn
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

I was going to suggest zipping the files but I have no experience working with zip files with php so I didn't even know if it was possible... php continues to amaze me :-)
User avatar
sharyn
Forum Commoner
Posts: 33
Joined: Tue Jun 15, 2004 6:39 pm
Location: So Cal

Post by sharyn »

This might do the trick : [ zlib ] Now all I have to do is figure out how to download one file :D

- sharyn
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

User avatar
sharyn
Forum Commoner
Posts: 33
Joined: Tue Jun 15, 2004 6:39 pm
Location: So Cal

[*RESOLVED*]

Post by sharyn »

ok all, I ended up using Zend's zip class and it works great. Thanks for all your help. :D

- sharyn
Post Reply