SWF Upload reports file too big even though it is smaller than the max size displayed.
|Reported by:||brianlayman||Owned by:|
|Component:||Media||Keywords:||upload, media, error, swfupload|
The issue is that swfupload.js can trigger a file_exceeds_size_limit error due to two different causes (that I know of) and WordPress assumes the cause is one of them.
In wp_include/script-loader.php, we define the response to file_exceeds_size_limit as:
'file_exceeds_size_limit' => sprintf(('This file is too big. Your php.ini upload_max_filesize is %s.'), @ini_get('upload_max_filesize')),
However, either max_post_size or upload_max_filesize can cause an file_exceeds_size_limit.
So, if my max_post_size is the still the default 8M, and my host increased upload_max_filesize to say 16M (from the default of 2M), uploading a 12M file would generate a "This file is too big. Your php.ini upload_max_filesize is 16M" and result in a very confused client.
A solution to this can be found at http://www.php.net/manual/en/ini.core.php#79564 I'm not sure if that's the final code we want, but the idea is the right one... Basically find the min of those two values (converting from M or K or w/e for compatibility) and display THAT in the error message.