# Downloading files from multi-document field

**URL:** <https://forum.wixstudio.com/t/downloading-files-from-multi-document-field/62435>\
**Category:** Ask the community\
**Tags:** wix-studio, question, code\
**Created:** [September 3, 2024, 12:06am UTC](https://forum.wixstudio.com/t/downloading-files-from-multi-document-field/62435 "2024-09-03T00:06:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Austin123](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/austin123/32/96520_2.png) [@Austin123](https://forum.wixstudio.com/u/Austin123)\
**Post date:** [September 3, 2024, 12:06am UTC](https://forum.wixstudio.com/t/downloading-files-from-multi-document-field/62435/1 "2024-09-03T00:06:30Z")

</div>

**Question:**  
How can I allow users to download the data from a multi-document field using a button.

**Product:**  
Wix Studio Editor

**What are you trying to achieve:**  
I have a multi-document field as a part of one of my collections and I would like for users of my site to be able to download this data with the click of a button (or several clicks).

**What have you already tried:**  
I’ve tried doing this using a repeater, a check list to select which files to download and a single button with a link to download all of the files in the field. Here is the code I’ve most recently been trying to get to work:

```javascript
import wixData from 'wix-data';

$w.onReady(function () {
    // Query your collection to get the list of items with multi-document fields
    wixData.query("Feedback") // Replace with your collection name
        .find()
        .then((results) => {
            // Assuming the repeater is connected to the items in the collection
            $w("#repeater4").data = results.items;
			console.error(results);
        })
        .catch((err) => {
            console.error(err);
        });
});

// This function runs for each item in the repeater
$w("#repeater4").onItemReady(($item, itemData, index) => {
    const docs = itemData.files; // Replace with your actual multi-document field key

    if (docs && docs.length > 0) {
        // If there are documents in the multi-document field, create a dynamic repeater for them
        $item("#docsRepeater").data = docs.map(doc => {
            return { fileName: doc.name, fileUrl: doc.fileUrl };
        });

        // For each document in the inner repeater
        $item("#docsRepeater").onItemReady(($docItem, docData, docIndex) => {
            $docItem("#text5").text = docData.fileName; // Display document name
            $docItem("#button75").link = docData.fileUrl; // Set the button to download the document
			console.error();
        });
    }
});

```

---

<div class="post-metadata">

**Author:** ![V-Blog](https://avatars.discourse-cdn.com/v4/letter/v/898d66/32.png) [@V-Blog](https://forum.wixstudio.com/u/V-Blog)\
**Post date:** [September 3, 2024, 4:48am UTC](https://forum.wixstudio.com/t/downloading-files-from-multi-document-field/62435/2 "2024-09-03T04:48:01Z")

</div>

Check this tread out - [Reddit - Dive into anything](https://www.reddit.com/r/WIX/comments/11cupyw/multidocument_download_link_on_item_page/)

---

<div class="post-metadata">

**Author:** ![Austin123](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/austin123/32/96520_2.png) [@Austin123](https://forum.wixstudio.com/u/Austin123)\
**Post date:** [September 3, 2024, 1:04pm UTC](https://forum.wixstudio.com/t/downloading-files-from-multi-document-field/62435/3 "2024-09-03T13:04:04Z")

</div>

Thanks that’s helpful but how would I then allow the user to upload documents to that second repeater? It’s convenient with the multi-document upload field because the user can upload to it with the click of a button.
