Forums

Display Multi Upload files

carlsore 01 Jul, 2013
I currently have an upload form to allow users to submit reports. I then have a CC list to allow my staff to view the submitted reports.

In switching up to CC4, I want to utilize the Multi Upload widget to allow those users to do more than one file, but I'm struggling with the syntax to get it to display again.

Here's the code (FE > Custom Listing Settings > Body) from the old report, using a single file upload field:
<tr>
<td>{user_submission_code}</td>
<td>{cf_created}</td>
<td><a href="/jupgrade/components/com_chronoforms/uploads/COG_Test/{filename}">View File</a></td>
</tr>


What's the right syntax to bring in the file array instead? OR...with v4, is there a better way to allow for access to those files from the front end?
GreyHead 05 Jul, 2013
Hi carlsore,

Please see this FAQ which may help; in your code I suspect that the jupgrade isn't needed.

Bob
carlsore 10 Jul, 2013
That does help some, but my question was more specifically re: the syntax of the link after using the multi-upload functionality. In my sample code, I can reference the {filename} parameter in my href=, but that's simple for single-upload, since "filename" is the name of the singular field in the table itself.

When using the newer multi-upload functionality, I've been struggling to identify how those references get stored in my table (in lieu of a single field to reference, does Chrono do a foreign key link of some type to another table as an array - filename[1], filename[2] - or when you set the max amount of attachments, does it then just look for filename1, filename2, filename3... in the resulting table)?

In short, in the FAQ you give the same code: <img src='{_PLUGINS_.upload_files.input_file_1.link}' />, and give the reminder to change the input_file_1 to match the name of your form input. For multi-upload, what IS the name of the form input?

In my sample, it defaulted to attachments_9[]...so to bring the files back, is it attachments_9[0], attachments_9[1], attachments_9[2]?

Thanks much - we get this going, definitely beer on me!

Hi carlsore,

Please see this FAQ which may help; in your code I suspect that the jupgrade isn't needed.

Bob

GreyHead 10 Jul, 2013
Hi carlsore,

It's midnight here so only a very quick answer. Add a debugger action and look at the output to see what has been added to the $form->data array. Then you can add the code to save whichever parts you need to the database.

Bob
Max_admin 14 Jul, 2013
Hello,

Chronoforms will just set an array of files names under the uploads name: attachments_9, it will be your task to save the files names list to a different table if you want with a foreign key pointing to the main table, then load the list back correctly.

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
carlsore 21 Jul, 2013

Chronoforms will just set an array of files names under the uploads name: attachments_9, it will be your task to save the files names list to a different table if you want with a foreign key pointing to the main table, then load the list back correctly.



Max - where/how would I configure those settings? I'm guessing it'd be in the Data Republish tab of the config, but for the Files Data Path, would that be the table name? Any chance there are screenshots available somewhere?

Thanks!!
Max_admin 22 Jul, 2013
Hi carlsore,

The settings are no where, you will have to code it!

e.g: if you drag a debugger action after the upload action, you should see an array of fields names under the "attachments_9", you will then have to use a "Custom code" action to copy that array into a new data key and prepare it for a new save in a related table:

<?php
foreach($form->data["attachments_9"] as $k => $file){
$form->data["Uploads"][$k]["data_id"] = $form->data["chronoform_data_cf_id"];//pkey value after first save
$form->data["Uploads"][$k]["filename"] = $file;
}
?>


Then use a new DB Save to save the uploads, you will have to configure it to "save under model id", and in this case the model id will be "Uploads".

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.