uri); if ($name != $file->filename) { $file->filename = $name; // Notify the user if this rename was due to an existing file (this is done by plupload/imce hooks) if ($replace == FILE_EXISTS_RENAME) { drupal_set_message(t('The file has been renamed to %filename.', array('%filename' => $file->filename))); } } // Global user may not be the owner. $file->uid = $imce['uid']; $file->status = FILE_STATUS_PERMANENT; $file->filemime = file_get_mimetype($file->uri); file_save($file); imce_file_register($file); drupal_set_message(t('%filename has been uploaded.', array('%filename' => $file->filename))); // Update file list. $img = imce_image_info($file->uri); $file->width = $img ? $img['width'] : 0; $file->height = $img ? $img['height'] : 0; imce_add_file($file, $imce); // Create thumbnails. if (isset($form_state['values']['thumbnails']) && $img) { imce_create_thumbnails($file->filename, $imce, $form_state['values']['thumbnails']); } } else { drupal_set_message(t('Upload failed.'), 'error'); } } } /** * Implements hook_element_info_alter(). */ function imce_plupload_element_info_alter(&$type) { if (isset($type['plupload'])) { $type['plupload']['#process'][] = 'imce_plupload_element_process'; } } /** * Process plupload element. */ function imce_plupload_element_process($element) { global $user; $imce_profile = imce_user_profile($user); // Remove extension validation if using IMCE. if ($imce_profile['extensions'] === '*') { unset($element['#upload_validators']['file_validate_extensions']); } return $element; }