Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function MYMODULE_admin() {
  2. $form = array();
  3. $form['style']['business_logo_fid'] = array(
  4. '#title' => t('Business Logo'),
  5. '#type' => 'managed_file',
  6. '#description' => t('Upload a logo for your business in one of the following formats: jpg png jpeg.'),
  7. '#default_value' => variable_get('business_logo_fid', ''),
  8. '#upload_validators' => array(
  9. 'file_validate_extensions' => array('jpg png jpeg'),
  10. ),
  11. '#upload_location' => 'public://',
  12. );
  13.  
  14. $form = system_settings_form($form);
  15. $form['#submit'][] = 'after_save_ui';
  16. return $form;
  17. }
  18.  
  19. function after_save_ui($form, &$form_state) {
  20.  
  21. $business_logo_fid = variable_get('business_logo_fid');
  22. if ($business_logo_fid) {
  23. $business_logo = file_load($business_logo_fid);
  24. $business_logo->status = FILE_STATUS_PERMANENT;
  25. file_save($business_logo);
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement