Forums

Multi Save File Upload

ctrlmedia 27 Nov, 2014
Hi guys,

I have another question.
I have a form which posts multiple values to the database for people, part example of array here:
(the form is much more complicated than this but I think this is the only part necessary here)

[peoplelist] => Array
        (
[0] => Array
                (
                    [peoplename] => starry star1
                    [peoplemessage] => starry star1
                    [uniq_id] => 7fbd0bef879952b60810d42b0ed555f301193390
                    [id] => 9
                    [peopleimage] => 
                )

            [1] => Array
                (
                    [peoplename] => SAMMY1
                    [peoplemessage] => 7777777777777
                    [uniq_id] => a8f442fb291127a89e16a58c8309a646a8b8816c
                    [id] => 10
                    [peopleimage] => 
                )

            [2] => Array
                (
                    [peoplename] => Steven 1
                    [peoplemessage] => 
                    [uniq_id] => 34946c66c1a6a899eeea7cc61b3641d9336bdbbd
                    [id] => 11
                    [peopleimage] => 
                )

            [3] => Array
                (
                    [peoplename] => Maria 9
                    [peoplemessage] => 222222 22222
                    [uniq_id] => 79473d3c86f0f2bdf8523b98e005e07d42559c0b
                    [id] => 12
                    [peopleimage] => 
                )




If I want to upload an image to one of the records in this array I would normally make a file field with a name like:
peoplelist[3][peopleimage]

but in the file upload action I don't think I can use this in the files config box? It doesn't work for me anyway.

So how would I upload a file to a specific record?

I also need to be able to add new records to this table at the same time so would need something like this to work:
(the other fields already work, its the file upload I am struggling to get working)

peoplelist[4][peopleimage] - to store the next record?


I am gathering that I may need to write a custom bit of code?

Any help and advice is much appreciated as usual!

Regards
Mark
ctrlmedia 27 Nov, 2014
I'm afraid the links supplied by the automated service calculus00 were not helpful in my case!
Regards
Mark
Max_admin 01 Dec, 2014
Answer
Hi Mark,

The easiest way to solve this is to use a plain field name like "field1", "field2"..etc and upload the files then use a custom code action after the upload to copy the values you need under the data path you like.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ctrlmedia 02 Dec, 2014
Hi Max,

That's exactly what I did. For anyone else interested, name the fields something basic like peopleimage0, peopleimage1 etc and then add some custom code in the submit area to put the contents in the array like the following:
<?php
if ($form->data["peopleimage0"] !=""){
$form->data["peoplelist"]["0"]["peopleimage"] = $form->data["peopleimage0"]; 
}
if ($form->data["peopleimage4"] !=""){
$form->data["peoplelist"]["1"]["peopleimage"] = $form->data["peopleimage1"]; 
}
?>


Hope it helps.
Regards
Mark
This topic is locked and no more replies can be posted.