Size validation doesn't work with FF3
Simbud - April 21, 2009 - 15:40
| Project: | Upload element |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
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.
| Attachment | Size |
|---|---|
| ff3.PNG | 36.59 KB |
| ie6.PNG | 8.28 KB |

#1
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;
}
?>
#2
Oups ! True ! Didn't thought admin could bypass the limitation.
Thanks for your quick answer and for your useful module :)
#3
;)