
If ( file_exists( $destination ) ) return esc_url( home_url( '/' ) ). Let me show you a simpler version: const urls = [Īs long as we have an array with the proper structure we can use that function to generate a ZIP file. Actually, we can go through DOM and find all the checked checkboxes along with finding the anchor sibling elements to get URLs. First of all, we need to store all links that we want to download files from into an array. But let me focus on a multiple files download option. However, I also need to allow users to download a single file, by clicking on the file name. Then the user needs to click the “Download” button. In my case, I have to select multiple files via checkboxes. Now in the file where you want to have that functionality, you need to import the installed package: import JSZip from "jszip" įinally, when we have all the necessary resources, we can start to work with the code. JavaScript versionįirst of all, you need to install and import 👉 this package 👈 npm install jszip I will show you how to download all the files using JavaScript and using PHP.

This way, the appropriate package will be prepared each time.ĭepending on your situation, you can prepare this in several ways. This can be very practical, especially when a client selects particular files that he or she would like to download. Thanks to this, we do not have to ask the client to add a separate zip file, because we can generate it automatically.

Such a ZIP file is generated dynamically by PHP. If you make various files on the website downloadable, you may also want to prepare a ZIP file containing all the items.
