2
我有一个输入字段类型为text和file的表单。我有一个没有保存在数据库中的文件名的问题,但其他一切都有。我vardumped $ myForm和一切都在那里,但文件,所以我创建了另一个数组与文件名,并与$ myForm合并。然后我试图将它设置为'jform',但它似乎不工作。任何人有任何想法,为什么?谢谢!无法使用JInput将文件名保存到数据库中
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();
}
可能会有所帮助 - https://groups.google.com/forum/?fromgroups=&hl=zh-CN#!topic/joomla-dev-general/63X0x5l9pP0 –
谢谢!结束使用$ _POST ['jform'] = $ merged_array; – Moo33