我正在尝试使用Joomla(JForm File Type)表单进行照片上传。提交表单和文件后,文件字段在数据库中保持为空。这里缺少什么?
我的字段与jdocs中的字段类似:
<field name="myfilevalue" type="file" label="Enter some text" description="Choose an image from your computer with maximum 100KB" size="10" accept="image/*" />
答案 0 :(得分:3)
据我所知,您需要在模型prepareTable
函数中手动处理该字段。
您可以使用以下方式访问该文件:
$jinput = JFactory::getApplication()->input;
$files = $jinput->files->get('jform');
$file = $files['myfilevalue']
$ file数组然后保存以下键:
您还需要将上传的文件实际移动到最终目的地。这可以使用JFile::upload()
完成。
另外,请确保您的表单设置了enctype="multipart/form-data"
,否则无效。