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