2013-04-01 45 views
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(); 
    } 
+2

可能会有所帮助 - https://groups.google.com/forum/?fromgroups=&hl=zh-CN#!topic/joomla-dev-general/63X0x5l9pP0 –

+0

谢谢!结束使用$ _POST ['jform'] = $ merged_array; – Moo33

回答

0

使用$ _ POST除非你打算编写大量的验证代码,以确保用户的输入。

相反,使用$jinput->get('jform', null, 'raw');

这仍然适用一些验证,但应确保你的价值观的机智。

相关问题