Blog Sections Open

Uploading Multiple Files with eForm in Evolution CMS

A practical pattern for multi-file eForm workflows that need to move several uploaded files into a per-submission folder.

Single-file upload examples are common. Multi-file form flows are where the real edge cases start showing up: nested file arrays, repeated validation, and path creation for each submission.

Typical pattern

The source workflow creates a folder per submission and loops through several uploaded files before sending the report email.

for ($i = 0; $i <= 2; $i++) {
    if ($_FILES['filename']['size'][$i] > 1024*1024*3) {
        // too large
    } else if (is_uploaded_file($_FILES['filename']['tmp_name'][$i])) {
        move_uploaded_file(
            $_FILES['filename']['tmp_name'][$i],
            'uploads/' . $_POST['ses'] . '/' . $_FILES['filename']['name'][$i]
        );
    }
}

What usually goes wrong

  • The form field uses array notation, but the PHP side treats it like one file.
  • Target folders are not created safely before the move step.
  • Validation mixes upload errors and business validation into one unreadable flow.

Safer direction

Create the target directory first, validate each file separately, sanitize filenames, and collect a clean result list before the mail or document-creation step runs. Multi-file uploads are much easier to debug when upload processing is isolated from the rest of the form logic.

Newer post

Showing a Link Only to a Specific User Group in Evolution CMS

How to render frontend links only for certain authorized users by checking group membership instead of relying on visible-but-unsafe UI tricks.

Older post

Getting a Resource Title and TV Value by Document ID

How to fetch another document’s title or TV value in Evolution CMS when you only have the resource ID available in the current template logic.