posted 11 years ago
Expanding on on Paul's explanation, HTTP is a 1-to-1 request/response protocol. You send 1 request, which is a URL GET, POST, or whatever, and the server returns 1 response, which can be a "file", a web page, or whatever.
You cannot return multiple responses from a single request, and you DEFINITELY cannot have your server select a directory on the client computer's disk drive and write a file into it. A file download is just an HTTP response data stream that has certain characteristics designed to alert the client to the need to save the response contents as a file instead of doing something like displaying it as a web page. The client will then display a dialog asking the user what directory that response should be written into as a file.
There is a reason for the dialog. It ensures that malicious servers cannot insert or replace critical system files with viruses. And it means that the server doesn't have to know anything about the client's filesystem or filesystem organization. I'm using a Linux machine, and there is no such thing as a "C" drive on Linux, any more than there is in IBM's z/OS. The web isn't a file server, after all.
You could automate the process of multiple file downloads by adding AJAX logic to the page that does the download request so that within that page, a succession of AJAX http request/response cycles are initiated, one for each file. But even then, the user will be prompted for the download directory on each file, due to the security constraints I mentioned earlier, commonly known as the "sandbox". A digitally-signed client-side logic module can avoid that, but that's not something you want to do lightly. It's usually very confusing and messy to get a client to accept a signed logic module. Microsoft ActiveVirus[TM] excepted.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer