> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: uploadFiles()

# Method package: w

# Method menu location: w --> UploadButton --> uploadFiles

# Method Link: https://dev.wix.com/docs/velo/velo-only-apis/$w/upload-button/upload-files.md

# Method Description:

Uploads the files that the site visitor has chosen.

The `uploadFiles()` function triggers the upload of the files in the
 upload button's [value](#value) property.
 The `uploadFiles()` function allows you to upload image, video, audio, document, and gallery (both images and video) files. You can upload multiple image, video, and gallery files at a time. 
 Use the `fileLimit` property to set the number of files you can upload at a time. 

 Note that this function does not yet support multiple audio and document file uploads. You can only upload audio and document files one at a time, and the `fileLimit` property is restricted to 1. 

 The upload button does not accept files larger than certain sizes, depending on the file type. Maximum allowed file sizes are listed [here](https://support.wix.com/en/article/supported-media-file-types-and-file-sizes).

 `uploadFiles()` returns promptly (meaning, it does not attempt to contact the upload server) with `UploadError` when either the `validityState`'s `fileSizeExceedsLimit` or `fileTypeNotAllowed` property is `true`.

> **Note:**
> This function replaces the deprecated
> `startUpload()`.
> The deprecated function will continue to work, but it will not receive updates.
> To keep any existing code compatible with future changes, see the
> [migration instructions](https://dev.wix.com/docs/velo/velo-only-apis/$w/upload-button/start-upload.md).



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Start a file upload

```javascript
$w("#myUploadButton").uploadFiles()
  .then( (uploadedFiles) => {
    uploadedFiles.forEach(uploadedFile => {
      console.log('File url:', uploadedFile.fileUrl);
    })
  })
  .catch( (uploadError) => {
    let errCode = uploadError.errorCode;  // 7751
    let errDesc = uploadError.errorDescription; // "Error description"
} );
```

## Typical file upload scenario

```javascript
$w("#myUploadButton").fileType = "Image"; // Site visitor can choose an image 
$w('#myButton').onClick( () => {                 
  if ($w("#myUploadButton").value.length > 0) {  // Site visitor chose a file
    console.log("Uploading the following files:")
    $w("#myUploadButton").uploadFiles()
      .then( (uploadedFiles) => {
        uploadedFiles.forEach(uploadedFile => {
        console.log("File url:" + uploadedFile.fileUrl);
        })
      console.log("Upload successful.");
      } )
      .catch( (uploadError) => {
      console.log("File upload error: " + uploadError.errorCode);
      console.log(uploadError.errorDescription);
      } );
  }
  else {  // Site visitor clicked button but didn't choose a file
    console.log("Please choose a file to upload.")
  }
} );


```

---