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.