내 요구 사항은 특정 폴더에 파일을 업로드하는 것입니다. 어떻게 양식 api를 사용하여이 작업을 수행 할 수 있습니까? upload_location이 동적이어야하는 코드 아래에서 어떻게 수정할 수 있습니까? 업로드 된 파일은 사용자가 제공 한 폴더 이름에 저장해야합니다.
# 제출 요소가 custom_document_submit 함수를 호출하지 않습니다.Form API에서 동적 파일 위치를 전달하는 방법은 무엇입니까?
$form['folder_name'] = array(
'#type' => 'textfield',
'#title' => t('Folder Name'),
);
$form['document'] = array(
'#type' => 'managed_file',
'#upload_validators' => array('file_validate_extensions' => array('xml')),
'#upload_location' => 'public://',
'#submit' => array('custom_document_submit'),
);
function custom_document_submit($form, &$form_state){
$destination = $form_state['values']['folder_name'];
$validators = array();
$file = file_save_upload('document', $validators, 'public://'.$destination);
}