# Uploading Images to CMS media gallery from custom form

**URL:** <https://forum.wixstudio.com/t/uploading-images-to-cms-media-gallery-from-custom-form/60371>\
**Category:** Ask the community\
**Tags:** wix-studio, cms, code, question\
**Created:** [June 30, 2024, 4:54am UTC](https://forum.wixstudio.com/t/uploading-images-to-cms-media-gallery-from-custom-form/60371 "2024-06-30T04:54:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaun\_Christian](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shaun_christian/32/92442_2.png) [@Shaun\_Christian](https://forum.wixstudio.com/u/Shaun_Christian)\
**Post date:** [June 30, 2024, 4:54am UTC](https://forum.wixstudio.com/t/uploading-images-to-cms-media-gallery-from-custom-form/60371/1 "2024-06-30T04:54:58Z")

</div>

**Question:**  
I have a question regarding how to properly upload images from a custom form with some text inputs and an upload button to pass photos to a CMS media gallery field in my data collection using Velo with the proper format.

**Product:**  
Wix Studio Editor

**What are you trying to achieve:**  
I am trying to pass up to 3 image files to my data collection media gallery field (field ID: images)

**What have you already tried:**

My relevant code is as follows:

$w.onReady(function () {  
$w(“#uploadButton”).fileType = ‘Gallery’; // Set fileType to ‘Gallery’

async function handleFileUploads() {  
const uploadButton = $w(“#uploadButton”);  
const files = uploadButton.value; // `value` to get the files list  
if (files.length === 0) {  
return ;  
}

console.log(“Files selected for upload:”, files);

const uploadResults = await uploadButton.uploadFiles();  
const failedUploads = uploadResults.filter(result =\> !result.fileUrl);  
if (failedUploads.length \> 0) {  
const errorMessages = failedUploads.map(f =\> f.validationMessage || “Unknown error”).join(", ");  
showValidationError("Some files failed to upload: " + errorMessages);  
return null;  
}

// Return ImageItem objects formatted for the media gallery  
return uploadResults.map(result =\> ({  
type: ‘image’,  
src: result.fileUrl,  
title: ‘Uploaded Image’,  
description: ‘’,  
link: ‘’  
}));  
}

Which results in this:

 ![image](https://us1.discourse-cdn.com/wix/original/3X/6/c/6c0211fd077a5d0c9064914960137b1d186c9ef2.png)

**Additional information:**  
I am relatively new to Velo and still have a lot to learn. Any guidance would be very much appreciated.

---

<div class="post-metadata">

**Author:** ![barb](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/barb/32/11137_2.png) [@barb](https://forum.wixstudio.com/u/barb)\
**Post date:** [December 28, 2025, 7:50pm UTC](https://forum.wixstudio.com/t/uploading-images-to-cms-media-gallery-from-custom-form/60371/2 "2025-12-28T19:50:01Z")

</div>

did you ever figure this out?

I used an upload button and was able to connect it to my CMS gallery field but I also want the user to add a title and description. I haven’t been successful doing that.

---

<div class="post-metadata">

**Author:** ![barb](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/barb/32/11137_2.png) [@barb](https://forum.wixstudio.com/u/barb)\
**Post date:** [December 28, 2025, 11:51pm UTC](https://forum.wixstudio.com/t/uploading-images-to-cms-media-gallery-from-custom-form/60371/3 "2025-12-28T23:51:36Z")

</div>

I figured out how to do upload a file to a gallery field type in my CMS. And to upload the title and description. Many iterations and errors (of mine) and it finally works. Here’s a link to my full post. [Media manager API - how to upload image and update title and description fields in the front-end](https://forum.wixstudio.com/t/media-manager-api-how-to-upload-image-and-update-title-and-description-fields-in-the-front-end/75704)
