I would like to know if there is any way to easily download many files to a user's computer at once via CGI. I have a script which retrieves certain files from other sites and downloads them. However, I would like to avoid copying them to my server and then to the user's computer (because of the space used and the time taken).
I had thought of packing all the files into an archive and letting the user download that, but I'm not really sure how to do that or how well it would work.
Is there any way to gain access to a user's computer (provided they give some sort of permission)? I know it is possible to upload files from a user's computer--is it possible to download files?
You cannot gain access to the user's computer and you can only return an octec stream for one file to the user (theoretically a MIME multipart respose should allow you to include multiple files, but this doesn't seem to be implemented). Alternately you could provide the user with links to the files they need, or pack them all into a zip and make them available from your server.
OK--that was basically the line of thought that I had. I was planning on using the archive approach--I tried returning an octet stream for the archive, and I tried downloading the file to the server. Neither way, however, seemed to work quite as I would like. When returning an octet stream, the filename given for the "Save as..." dialog box had a .pl extension instead of the .zip that I was actually sending...there are probably ways around this though...I really don't know too much about that sort of thing.
And then, storing the file on the server is alright except that I am not on my own server and I have limited space. Some of the files are fairly large, and if multiple users had archives stored at the same time, it could be a problem. And then there is the problem of how long to wait before deleting the archives off the server...
Anyway, I have decided to make a Perl program instead of a CGI script. It fits the purpose a lot better (if you've seen my other post, you know that I also want to provide feedback on the script while it is executing--not exactly what CGI and browsers would like to do). I'm writing a C++ program to wrap the script and capture the output to form it into a nice dialog box...anyway, I think I've got it figured out.
Thank you, though, for confirming my thoughts--I know relatively little about downloading files via Perl (I don't think I have any scripts that use anything besides text/html), so I wanted to make sure there wasn't another approach.