A multipart upload can contain three valid photos and still put the wrong person in the center. The problem starts when the app treats the files as an unlabeled list. Give each input a stable slot ID, then use that ID from the browser all the way to the renderer.

The template library at Christmas Dance AI is a useful example of why this matters. It offers solo, duo, and trio layouts with one photo per dancer. Its Jingle Bell Brazil Trio instructions define left and right from the camera's view. In an uploader for a layout like this, make that convention visible before the user chooses any files.

Build a local check for the three slots

Save the example below as preflight.html and open it in a browser. It accepts one JPEG, PNG, or WebP per slot and uses a demo limit of 10,000,000 bytes per file. The button checks each slot and prints a manifest of the assignments. Image decoding happens in the browser using a temporary blob URL. The page makes no upload request.

<!doctype html> <html lang="en"> <meta charset="utf-8"> <title>Check image slots</title> <form id="preflight"> <p>Use screen positions as seen by the camera.</p> <label>Screen left <input name="left" type="file" accept="image/jpeg,image/png,image/webp"></label> <label>Center <input name="center" type="file" accept="image/jpeg,image/png,image/webp"></label> <label>Screen right <input name="right" type="file" accept="image/jpeg,image/png,image/webp"></label> <button type="submit">Check image slots</button> </form> <pre id="report" aria-live="polite"></pre> <script type="module"> const slots = ["left", "center", "right"]; const maxBytes = 10_000_000; const mimeTypes = new Set(["image/jpeg", "image/png", "image/webp"]); const form = document.querySelector("#preflight"); const report = document.querySelector("#report"); let revision = 0; async function inspect(slot, file) { if (!file) return { slot, error: "Choose a photo." }; if (!file.size || file.size > maxBytes) { return { slot, error: "Choose a nonempty photo of at most 10 MB." }; } if (!mimeTypes.has(file.type)) { return { slot, error: "Choose a JPEG, PNG, or WebP photo." }; } const image = new Image(); const url = URL.createObjectURL(file); try { image.src = url; await image.decode(); return { slot, bytes: file.size, width: image.naturalWidth, height: image.naturalHeight, }; } catch { return { slot, error: "The browser could not decode this image." }; } finally { URL.revokeObjectURL(url); } } form.addEventListener("change", () => { revision += 1; report.textContent = "Selection changed. Run the check again."; }); form.addEventListener("submit", async (event) => { event.preventDefault(); const run = ++revision; const files = slots.map((slot) => form.elements.namedItem(slot).files[0]); report.textContent = "Checking…"; const results = []; for (const [index, slot] of slots.entries()) { results.push(await inspect(slot, files[index])); if (run !== revision) return; } const errors = results.filter((row) => row.error); report.textContent = errors.length ? errors.map(({ slot, error }) => `${slot}: ${error}`).join("\n") : JSON.stringify(results, null, 2); }); </script> 

The accept attribute guides the file picker. The MIME check here uses browser-supplied metadata, and decode() answers whether this browser can read the selected image. Keep the slot contract when you add a server endpoint. Send each image under its named multipart field. On the server, require exactly one file for each slot the selected template declares, enforce request and per-file size limits, and verify the file format and dimensions with your image decoder before queueing work. Build the renderer's input in template order using those slot names. Decode images under a pixel budget too, since a small encoded file can expand into a large image.

Try the cases that can swap people

  • Selection order. Pick the right photo first, then left, then center. The manifest should list left, center, and right. Use test images with different dimensions so you can identify each assignment in the output.
  • Missing center. Leave the center empty and run the check. The report should identify the center slot as missing.
  • Unreadable file. Take a test JPEG, truncate a copy to its first few bytes, and keep the .jpg extension. If the browser reports it as image/jpeg, it should reach the decode check and fail there.
  • Edits during a check. Change a file while decoding is in progress. The earlier run should stop updating the report. Run the check again to see the current assignments.

Keep the same slot labels if you add thumbnails to the confirmation screen. Users can then check who goes where before the files leave their device. For photos of people, ask for permission to use each photo and make that requirement visible near the upload controls.

References

This article was generated by an AI writer on behalf of the Christmas Dance AI project, which is referenced as an example.