Blog Sections Open
Uploading Images Through eForm in Evolution CMS
How to combine eForm callbacks, file uploads, and document creation in one workable Evolution CMS form flow.
eForm can do much more than send an email. With a small callback layer it can also accept an uploaded file, move it into storage, and create a new resource with TV data taken from the same submission.
That makes it useful for classifieds, profile submissions, portfolios, and any workflow where the editor should receive a ready-made document instead of a raw email.
The two moving parts
The original workflow uses one function to process the uploaded file and another to create the new document:
<?php
function ParseForm(&$fields){
$target_path = "/home/example/www/uploads/";
$target_path = $target_path . basename($_FILES['attach']['name']);
if (move_uploaded_file($_FILES['attach']['tmp_name'], $target_path)) {
return true;
}
return false;
}
?>
<?php
function CreateNewArticle(&$fields){
require_once('assets/libs/document.class.inc.php');
$doc = new Document();
$doc->Set('parent', 51);
$doc->Set('template', 8);
$doc->Set('published', 1);
$doc->Set('pagetitle', 'Ad ' . $fields['ses']);
$doc->Set('alias', 'ad' . $fields['ses']);
$doc->Set('content', $fields['comment']);
$doc->Set('tvemail', $fields['email']);
$doc->Set('tvname', $fields['name']);
$doc->Set('tvprice', $fields['price']);
$doc->Save();
return true;
}
?>
What matters most
- The form must use
enctype="multipart/form-data". - The upload field name in the form must match the key used in
$_FILES. - The destination directory must already exist and be writable by PHP.
- You should never trust the raw file name without validation and sanitizing.
Safer improvements
In modern Evo projects it is better to generate a unique file name, validate MIME type and extension, and store the final path in a TV or content field. That prevents collisions and keeps uploaded files from overwriting one another.
$ext = pathinfo($_FILES['attach']['name'], PATHINFO_EXTENSION);
$filename = uniqid('upload_', true) . '.' . strtolower($ext);
When this pattern works well
This approach is a good fit when the submitted data should become a real Evo document with TVs, aliases, and standard frontend rendering. If the submission only needs to be moderated first, you can still create the resource unpublished and let editors review it in the manager.
The key idea is simple: let eForm handle validation, keep upload processing explicit, and only create the document after the uploaded file has been accepted successfully.
Debugging Shopkeeper Orders That Never Reach the Mailer
A practical checklist for Shopkeeper and eForm setups where the cart works but the final order data never arrives by email.
Handling Babel and phpThumbOf Across Language Contexts
How to keep image TVs, Babel-linked resources, and phpThumbOf output working correctly when one Evolution CMS site serves multiple language contexts.