1. ruud
  2. General
  3. Thursday, December 04 2014, 11:23 AM
Hi,

been helping a user upload her avatar. It turned out that the avatar file size was to big, which is strange.
Investigated it and found a potential issue in your code and have an improvement suggestion.

When specifying the upload_max_filesize in php.ini it is allowed to use a Shorthand notation.
In my case i have set this value to 1G

In your code you read the value $max_upload = (int)(ini_get('upload_max_filesize'));
and evaluate the uploaded file size like this: } else if ( $image['size'] > $upload_limit*100*100*100 ) {

what happens is that the maximum file size limit is not 1G but appr. 1M (because you multiply 1 by 100 * 100 * 100)

The 1G value is not correct converted! resulting in a wrong upload limit.

Furthermore:
the errors are hard coded into the code, it would make more sense to make these part of the language file. In that way I can make dutch translations for them :)

$errors = array(
0 => "The file is to big. Upload a image under $upload_limit",
1 => 'This file extension is not allowed !',
2 => "Error."
);

Hope this helps :)
regards,
Ruud.
Accepted Answer
admin Accepted Answer
Admin
wow you have right!!
we will fix these issue in next release.

The 1G value is not correct converted! resulting in a wrong upload limit.
this would be very rare :D but we will fix, anyway in future we want to add parameter to set max upload size for each image(and avatar) and file type field
  1. more than a month ago
  2. General
  3. # Permalink
ruud Accepted Answer
Content Protected
  1. more than a month ago
  2. General
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.