두 가지 문제점이 있습니다.임시 파일을 제거하고 drupal에서 업로드를 확인하십시오.
1) 파일 업로드를 테스트 할 때 동일한 파일을 반복해서 업로드합니다. 그러나 drupal은 각 파일의 끝에 증분 번호를 추가합니다. 어느 쪽이 좋습니까?하지만 오래된 파일을 덮어 쓰겠습니다. file_copy()
과 다른 방법을 사용해야합니까? drupal이 업로드 된 모든 파일에 대한 내부 참조를 유지한다는 것을 알고 있습니다. 나는 대신 Drupal을 사용할 필요가 없습니다.
if (file_exists) {
confirmation('do you still want to upload this file?');
// if yes foo_file_submit($form, &$form_state, 'confirmed');
} else {
foo_file_submit($form, &$form_state);
}
지금까지
function foo_file_validate($form, &$form_state) {
$file = file_save_upload('file', array(
//'file_validate_is_image' => array(), // Validates file is really an image.
'file_validate_extensions' => array('jpg'), // Validate extensions.
));
// If the file passed validation:
if ($file) {
// Prepare the file to upload
$filepath = 'public://foo/files';
file_prepare_directory($filepath, FILE_CREATE_DIRECTORY); // Create the folder if it doesn't exist
// Move the file, into the Drupal file system
if ($file = file_copy($file, $filepath)) {
// Save the file for use in the submit handler.
$form_state['storage']['file'] = $file;
}
else {
form_set_error('file', t('Failed to write the uploaded file to the site\'s file folder.'));
}
}
else {
form_set_error('file', t('No file was uploaded.'));
}
}
이 무엇 : 파일 이름이 이미 내가 쓸 수있는 방법이있는 경우
2) 나는 내 자신의 추가 정보를 데이터베이스에 파일 이름을() 추가 해요
감사합니다. 하지만 파일이 있으면 confirm_form()을 반환 할 수 있습니까? 나는 그것을 검증 함수에 추가하려고 시도했지만 작동시키지 못한다. – user2988129