Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End php download multiple files problem. Reply To: php download multiple files problem.

#185127
__
Participant

Btw, I read that I should use POST instead of GET because GET can often be cached which I don’t want. Each time the user selects new images and does the zip/download they need to be correct and not the previous selections.

If you’ll notice, our PHP function sets Cache-Control and Expires headers, which instruct browsers and intermediate servers not to cache the page. This is the correct way to do things.

GET is for requesting things from the server. It is called an “idempotent” or “safe” method, because there is no risk of creating unintended side effects on the server.

POST is for giving data to a server. It is a “non-idempotent” method, because there is an expectation that the data might cause changes on the server (e.g., changing a record in a database, or saving an uploaded file).

We’ve got two different approaches to your file download:

  • create an iframe that downloads an existing file from the server.
  • send a list of filenames to the server, which will then zip those files together so they can be downloaded.

Now that you know what the difference between GET and POST is, can you see which method goes with each approach?