function file_save_upload
这个函数依然存在啊
=============================
$validators = array( 'file_validate_extensions' => array('pdf'), ); $form['my_file'] = array( '#type' => 'managed_file', '#name' => 'my_file', '#title' => t('File *'), '#size' => 20, '#description' => t('PDF format only'), '#upload_validators' => $validators, '#upload_location' => 'public://my_files/', );
--
here is a bug
https://www.drupal.org/project/drupal/issues/2884052
-----
use DrupalfileEntityFile;
$fid = $form_state->getValue(['test_CERTIFICATE', 0]);
if (!empty($fid)) {
$file = File::load($fid);
$file->setPermanent();
$file->save();
}
---------------
You could check for an existing file with the same name before you make the temporary file permanent. – 4k4 Jul