2

I have a form with input fields of type text and file. I have a problem of the filenames not saving in the database but everything else does. I vardumped $myForm and everything is there but the files, so I created another array with the filenames and merged it with $myForm. I then tried to set it to 'jform' but it doesn't seem to be working. Anyone have any ideas to why? Thanks!

controller.php

 function save()
    {
        $jinput = JFactory::getApplication()->input;
        $myForm = $jinput->get('jform', null, 'array');
        //$files = $jinput->files->get('jform');
        $file_array = ['image1' => 'test.png',
                            'image2' => 'test2.png'];

        $merged_array = array_merge($myForm, $file_array);
        $jinput->set('jform',$merged_array);
        //or $jinput->post->set('jform',$merged_array); (this doesn't work either)

        return parent::save();
    }
George Wilson
  • 5,595
  • 5
  • 29
  • 42
Moo33
  • 1,251
  • 3
  • 15
  • 27

1 Answers1

0

Do not use $_POST unless you plan on writing extensive validation code to secure the user input.

Instead, use $jinput->get('jform', null, 'raw');

This will still apply some validation, but should keep your values in tact.

3rdLion
  • 159
  • 2