My issue is in regards to file uploads.
Everything is working fine, just from the point of the client I want the file upload to appear in the database record as a link to the file as opposed to text.
I have done research for several hours and am stumped as to how I would do this. I know there are ways to have it appear in the email but I would like it to appear in the database.
Everything is working fine, just from the point of the client I want the file upload to appear in the database record as a link to the file as opposed to text.
I have done research for several hours and am stumped as to how I would do this. I know there are ways to have it appear in the email but I would like it to appear in the database.
Hi cruz777,
Add a Debugger action after the Upload File action to see exactly what data is created. You will see the file URL there as one entry in the _PLUG-INS_ block like this:
Add a Custom Code action after the Upload Files action and before the DB Save action and add code like this:
Where file_url needs to be the column name in the database table.
Bob
Add a Debugger action after the Upload File action to see exactly what data is created. You will see the file URL there as one entry in the _PLUG-INS_ block like this:
[_PLUGINS_] => Array (
[upload_files] => Array (
[upload_file] => Array(
[name] => 20130508050631_58840_565366930151843_1517328009_n.jpg
[original_name] => 58840_565366930151843_1517328009_n.jpg
[path] => /home/xxx/components/com_chronoforms/uploads/form_name/file_name.jpg
[size] => 41327
[link] => http://example.com/components/com_chronoforms/uploads/form_name/file_name.jpg
)
)
)
Add a Custom Code action after the Upload Files action and before the DB Save action and add code like this:
<?php
$form->data['file_url'] = $form->data['_PLUGINS_']['upload_files']['upload_file']['link'];
?>
Where file_url needs to be the column name in the database table.
Bob
Great, thanks that worked a treat!
I then looked at getting this to print as a link instead of just a URL - I tried adding this:
However, when it prints it out to the database it acts as a string so it isn't clickable when viewing. Is there anyway to fix this? Is there a PHP parsing method I am missing here?
I then looked at getting this to print as a link instead of just a URL - I tried adding this:
<?php
$form->data['UploadCV'] = '<a href="'.$form->data['_PLUGINS_']['upload_files']['UploadCV']['link'].'">Form</a>';
?>
However, when it prints it out to the database it acts as a string so it isn't clickable when viewing. Is there anyway to fix this? Is there a PHP parsing method I am missing here?
Hi cruz777,
You could try changing the quotes to:
If you want a clickable link then I'd probably save just the URL and build a data viewer listing either with a ChronoForm using the DB Multi-REcord Loader, or with ChronoConnectivity. That gives you much better control.
Bob
You could try changing the quotes to:
<?php
$form->data['UploadCV'] = "<a href='{$form->data['_PLUGINS_']['upload_files']['UploadCV']['link']}'>Form</a>";
?>
but I'm not sure that will work in the data viewer. I assume that is where you are looking at it from?If you want a clickable link then I'd probably save just the URL and build a data viewer listing either with a ChronoForm using the DB Multi-REcord Loader, or with ChronoConnectivity. That gives you much better control.
Bob
This topic is locked and no more replies can be posted.