Published on
Sometimes uploaded files are too large to attach and email so it is more helpful to add a link; or you may want to show an image file to confirm what has been up loaded. This FAQ shows you how to build links to use in Email templates and Thank You Page actions.
ChronoForms v4
The ChronoForms Upload Files action adds some useful information about the file in the $form->data array. here's an example:
[_PLUGINS_] => Array ( [upload_files] => Array ( [input_file_1] => Array ( [name] => 20121022093603_test_image.jpg [original_name] => test_image.jpg [path] => C:\xampp\htdocs\components\com_chronoforms\uploads\form_name\20121022093603_test_image.jpg [size] => 12597 [link] => http://example.com/components/com_chronoforms/uploads/form_name/20121022093603_test_image.jpg ) ) )
You can see exactly what is there in your form by adding a Debugger action temporarily to the On Submit event.
We can use this information in an email template or a Thank You Page action with the curly brackets syntax. For example the 'link' value would be {_PLUGINS_.upload_files.input_file_1.link}.
Note that input_file_1 is the name of the File Input element form the form so your form may be different.
So, to create a link using the file name as the display text we can use:
<a href='{_PLUGINS_.upload_files.input_file_1.link}' >{_PLUGINS_.upload_files.input_file_1.name}</a>
or to display the image, if the upload is an image file:
<div><img src='{_PLUGINS_.upload_files.input_file_1.link}' /></div>
Remember to change the input_file_1 part to match the name of the File Upload input in your form.
ChronoForms v5
In ChronoForms v5 the uploaded file data is added to a new $form->files array like this:
$form->files => array( [input_name] => array( ['name'] // the name of the file ['link'] // the URL of the file ['path'] // the folder path of the file ['size'] // the size of the file ) )
To display a link or a image after the form is submitted use a Custom Code element with code like this:
<?php echo "<a href='{$form->files['input_name']['link']}' >{$form->files['input_name']['name']}</a>"; ?>
or
<?php echo "<img src='{$form->files['input_name']['link']}' />"; ?>
Comments: