如何使用表单元素类型文件以drupal8格式上传文件?
我想上传文件,我必须将表单元素类型用作“文件”。在提交功能中,我无法获取与我正在上传的文件有关的任何适当数据。有人可以帮我解决这个问题吗?请找到以下代码: public function buildForm(array $form, FormStateInterface $form_state) { $form['test_CERTIFICATE'] = [ '#type' => 'file', '#title' => $this->t('Certificate'), '#description' => $this->t('Your Certificate (.pem file)').': '.\Drupal::state()->get('test_CERTIFICATE_NAME'), ]; return parent::buildForm($form, $form_state); } 提交功能: public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $validators = array('file_validate_extensions' => array('pem')); $files = file_save_upload('test_CERTIFICATE', $validators, 'public://certfiles', FILE_EXISTS_REPLACE); …