Here's the code I use :

$form['image'] = array(
'#type' => 'image_upload_element',
'#attributes' => array("enctype" => "multipart/form-data"),
'#title' => t('Image'),
'#image_preview_size' => '120x250',
'#file_validators' => array(
  'file_validate_size' => array(10240),
  'file_validate_extensions' => array('png gif jpg jpeg'),
        ),
  );

As you can see on screen-shots attached, the upload is forbidden on IE6 but not on FF3.

CommentFileSizeAuthor
ie6.PNG8.28 KBSimbud
ff3.PNG36.59 KBSimbud
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Alan D.’s picture

Were you logged in as admin user? (uid = 1)

The module is using core Drupal file size validation that allows the admin user to bypass the size restrictions:

Eg:

<?php
function file_validate_size($file, $file_limit = 0, $user_limit = 0) {
  global $user;

  $errors = array();

  // Bypass validation for uid  = 1.
  if ($user->uid != 1) {
    if ($file_limit && $file->filesize > $file_limit) {
      $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit)));
    }

    $total_size = file_space_used($user->uid) + $file->filesize;
    if ($user_limit && $total_size > $user_limit) {
      $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit)));
    }
  }
  return $errors;
}
?>
Simbud’s picture

Oups ! True ! Didn't thought admin could bypass the limitation.

Thanks for your quick answer and for your useful module :)

Alan D.’s picture

Status: Active » Closed (fixed)

;)