Blog Sections Open
Handling File Uploads in FormLister
How to make FormLister file uploads work reliably, especially inside modal and AJAX-based forms.
A common FormLister upload problem looks like this: the form submits, validation runs, but the user still sees messages such as “file not selected” or “attach a document”. In practice the issue is usually not the modal window itself. It is almost always the form markup.
If your form includes file inputs, the browser must send the request as multipart/form-data. Without that encoding PHP receives an empty file payload, and FormLister behaves as if nothing was uploaded.
Minimal working pattern
[!FormLister?
&formid=`uploadForm`
&to=`team@example.com`
&subject=`New uploaded document`
&rules=`{
"name":{"required":"Enter your name"},
"document":{"required":"Attach a document"}
}`
&formTpl=`@CODE:
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="formid" value="uploadForm">
<input type="text" name="name" value="[+name.value+]" placeholder="Name">
<input type="file" name="document">
[+document.error+]
[+form.messages+]
<button type="submit">Send</button>
</form>`
&reportTpl=`@CODE:
<p>Name: [+name.value+]</p>
<p>Document: [+document.value+]</p>`
!]
Checklist for modal forms
- the form must have
method="post" - the form must have
enctype="multipart/form-data" - the file input must have a real
nameattribute - your JavaScript submit handler must not strip the file field when sending AJAX requests
If you submit the form through JavaScript, use FormData and let the browser send the multipart payload. Serializing the form into a query string will drop the uploaded file.
const form = document.querySelector('#upload-form');
const data = new FormData(form);
fetch(form.action, {
method: 'POST',
body: data
});
Why this matters
A common real-world case involves a modal window on Evolution CMS 1.4.12 and a file field that always failed validation. That pattern still appears today whenever a modal or AJAX layer changes the request format. Start by checking the form encoding before debugging FormLister itself.
Migrating Web Users with Extended Rights from Evolution 2.0.4 to 3.x
A practical migration guide for moving web users with extended permissions from Evolution 2.0.4 into Evolution CMS 3.x.
Building a Container Wrapper in MultiFields
A practical way to wrap MultiFields output in a slider, grid, or other reusable container in Evolution CMS.