# Stack Files into a single doc

**URL:** <https://forums.creativeclouddeveloper.com/t/stack-files-into-a-single-doc/4795>\
**Category:** UXP Plugin API\
**Created:** [June 14, 2022, 3:02pm UTC](https://forums.creativeclouddeveloper.com/t/stack-files-into-a-single-doc/4795 "2022-06-14T15:02:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JokerMartini](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jokermartini/32/2207_2.png) [@JokerMartini](https://forums.creativeclouddeveloper.com/u/JokerMartini)\
**Post date:** [June 14, 2022, 3:02pm UTC](https://forums.creativeclouddeveloper.com/t/stack-files-into-a-single-doc/4795/1 "2022-06-14T15:02:16Z")

</div>

Is there a way in which I can loop through a list of images the user has selected, and then stack them into a single doc?

```auto
const fs = require("uxp").storage.localFileSystem;
const fileTypes = require("uxp").storage.fileTypes;

async function stackImages(files) {
  const app = window.require("photoshop").app;
  if (files.length > 0) {
    const file = files[0];

    // open first image
    const app = require("photoshop").app;
    await app.open(file);

    // stack the rest
  }
}

async function openFileBrowser() {
  const files = await fs.getFileForOpening({
    allowMultiple: true,
    types: fileTypes.images,
  });
  if (files.length > 0) {
    stackImages(files);
  }
}

document.getElementById("btnOpen").addEventListener("click", openFileBrowser);

```
