Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
create folders using taxonomy terms and use this field widget in file types . Use this folders to upload image in particular location instead of upload it in root.
use this code
if(!empty($file->field_folder) && empty($form_state['values']['replace_upload'])){
$tname = taxonomy_term_load($file->field_folder['und'][0]['tid']);
$file = file_move($file,$form_state['values']['scheme'] . '://'.$tname->name,FILE_EXISTS_RENAME);
}
in
function file_entity_edit_submit($form, &$form_state)
and above the line of file_save($file);
Comment | File | Size | Author |
---|---|---|---|
#2 | Screenshot (34)_0.png | 41.71 KB | sri@re |
#2 | Screenshot (33)_0.png | 32.12 KB | sri@re |
#2 | Screenshot (32).png | 46.86 KB | sri@re |
Comments
Comment #2
sri@re CreditAttribution: sri@re commentedComment #3
joseph.olstadPlease, only one open issue for same issue at the same time.
Improve issue summary formatting and refer to duplicate issue.
Comment #4
sri@re CreditAttribution: sri@re commentedAnother solution to add file in folder. Created og group field in file types of image . And make that og group name as folder name and stored files in folder(og wise)wise.
in function file_entity_edit_submit($form, &$form_state) before the line of file_save.