Last active
December 30, 2015 22:59
-
-
Save lsolesen/7898229 to your computer and use it in GitHub Desktop.
How to actually upload the file, so I can use it elsewhere?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @file | |
| * VIH Kalendersiden admin settings. | |
| */ | |
| /** | |
| * Return the VIH Kalendersiden global settings form. | |
| */ | |
| function vih_kalendersiden_admin_settings() { | |
| $form['vih_kalendersiden_headline'] = array( | |
| '#type' => 'textfield', | |
| '#title' => t('Calendar headline'), | |
| '#required' => TRUE, | |
| '#default_value' => variable_get('vih_kalendersiden_headline', t('Vejle Idrætshøjskole')), | |
| '#description' => t('Headline to show on the calendar.'), | |
| ); | |
| $form['vih_kalender_logo_image'] = array( | |
| '#type' => 'managed_file', | |
| '#name' => 'vih_kalender_logo_image', | |
| '#title' => t('Logo'), | |
| '#size' => 40, | |
| '#description' => t('Do not upload an image too big'), | |
| '#upload_location' => 'public://kalendersiden/', | |
| '#default_value' => variable_get('vih_kalendersiden_logo_image'), | |
| ); | |
| return system_settings_form($form); | |
| } | |
| /** | |
| * Implements hook_settings_submit(). | |
| */ | |
| function vih_kalendersiden_admin_settings_submit($form, &$form_state) { | |
| if (isset($form_state['values']['vih_kalendersiden_logo_image'])) { | |
| $file = file_load($form_state['values']['vih_kalenderside_logo_image']); | |
| $file->status = FILE_STATUS_PERMANENT; | |
| file_save($file); | |
| variable_set('vih_kalendersiden_logo_image', $file->fid); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uploads, but I am not able to access the file afterwards using variable_get() and the file name is not shown on the admin form.